Skip to content

Commit c181b87

Browse files
committed
Allow folder-level setting of 10x defaults
1 parent 92b1f80 commit c181b87

File tree

6 files changed

+250
-3
lines changed

6 files changed

+250
-3
lines changed

singlecell/resources/views/cDNAImport.view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<dependencies>
33
<dependency path="laboratory.context" />
44
<dependency path="extWidgets/ExcelUploadPanel.js"/>
5+
<dependency path="singlecell/panel/TenxSettingsPanel.js"/>
56
<dependency path="singlecell/panel/PoolImportPanel.js"/>
67
<dependency path="singlecell/panel/cDNAImportPanel.js"/>
78

singlecell/resources/views/poolImport.view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<dependencies>
33
<dependency path="laboratory.context" />
44
<dependency path="extWidgets/ExcelUploadPanel.js"/>
5+
<dependency path="singlecell/panel/TenxSettingsPanel.js"/>
56
<dependency path="singlecell/panel/PoolImportPanel.js"/>
67

78
<dependency path="internal/jQuery"/>

singlecell/resources/web/singlecell/panel/PoolImportPanel.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
5656
name: 'assaytype',
5757
labels: ['Assay Type', 'Assay Type', 'Assay', 'treatment'],
5858
allowRowSpan: false,
59+
alwaysShow: true,
5960
allowBlank: false,
6061
transform: 'assaytype'
6162
},{
@@ -159,11 +160,16 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
159160
},
160161

161162
assaytype: function(val, panel) {
163+
var requireAssayType = panel.down('#requireAssayType').getValue();
162164
if (val && (val === '--' || val === '-')) {
163-
val = 'N/A';
165+
val = null;
166+
}
167+
168+
if (!requireAssayType && !val) {
169+
return 'N/A';
164170
}
165171

166-
return val || 'N/A';
172+
return val;
167173
},
168174

169175
subject: function(val, panel) {
@@ -387,6 +393,28 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
387393
});
388394

389395
this.callParent(arguments);
396+
397+
Ext4.Msg.wait('Loading...');
398+
LABKEY.Ajax.request({
399+
method: 'POST',
400+
url: LABKEY.ActionURL.buildURL('singlecell', 'getTenXImportDefaults'),
401+
scope: this,
402+
success: function(response){
403+
LDK.Utils.decodeHttpResponseJson(response);
404+
if (response.responseJSON){
405+
this.configDefaults = response.responseJSON;
406+
for (var name in this.configDefaults){
407+
var item = this.down('#' + name);
408+
if (item){
409+
item.setValue(this.configDefaults[name]);
410+
}
411+
}
412+
413+
Ext4.Msg.hide();
414+
}
415+
},
416+
failure: LDK.Utils.getErrorCallback()
417+
});
390418
},
391419

392420
getPanelItems: function(){
@@ -466,6 +494,31 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
466494
linkCls: 'labkey-text-link',
467495
href: LABKEY.ActionURL.buildURL('query', 'executeQuery', Laboratory.Utils.getQueryContainerPath(), {schemaName: 'singlecell', 'query.queryName': 'stim_types'}),
468496
style: 'margin-top: 10px;'
497+
}, {
498+
xtype: 'ldk-linkbutton',
499+
width: null,
500+
hidden: !LABKEY.Security.currentUser.isAdmin,
501+
text: 'Set Page Defaults',
502+
itemId: 'copyPrevious',
503+
linkCls: 'labkey-text-link',
504+
scope: this,
505+
handler: function (btn) {
506+
Ext4.create('Ext.window.Window', {
507+
title: 'Set Page Defaults',
508+
items: [{
509+
xtype: 'singlecell-tenxsettingspanel',
510+
border: false,
511+
hidePageLoadWarning: false,
512+
hideButtons: true
513+
}],
514+
buttons: SingleCell.panel.TenxSettingsPanel.getButtons().concat([{
515+
text: 'Cancel',
516+
handler: function (btn) {
517+
btn.up('window').close();
518+
}
519+
}])
520+
}).show();
521+
}
469522
},{
470523
xtype: 'textfield',
471524
style: 'margin-top: 20px;',
@@ -506,6 +559,11 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
506559
fieldLabel: 'Require Cite-Seq Library',
507560
itemId: 'requireCITE',
508561
checked: false
562+
},{
563+
xtype: 'checkbox',
564+
fieldLabel: 'Require Assay Type',
565+
itemId: 'requireAssayType',
566+
checked: true
509567
},{
510568
xtype: 'checkbox',
511569
fieldLabel: 'Combine Hashing and Cite-Seq Libraries',
@@ -1049,6 +1107,7 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
10491107
var data = [];
10501108
var missingValues = false;
10511109
var requireHTO = this.down('#requireHTO').getValue() || (this.down('#requireHashTag') && this.down('#requireHashTag').getValue());
1110+
var requireAssayType = this.down('#requireAssayType').getValue()
10521111
Ext4.Array.forEach(parsedRows, function(row, rowIdx){
10531112
var toAdd = [rowIdx + 1];
10541113
Ext4.Array.forEach(colIdxs, function(colIdx){
@@ -1060,6 +1119,10 @@ Ext4.define('SingleCell.panel.PoolImportPanel', {
10601119
allowBlank = false;
10611120
}
10621121

1122+
if (requireAssayType && colDef.name == 'assaytype') {
1123+
allowBlank = false;
1124+
}
1125+
10631126
if (allowBlank === false && Ext4.isEmpty(row[propName])){
10641127
missingValues = true;
10651128
toAdd.push('MISSING');
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Ext4.define('SingleCell.panel.TenxSettingsPanel', {
2+
extend: 'Ext.panel.Panel',
3+
alias: 'widget.singlecell-tenxsettingspanel',
4+
5+
hidePageLoadWarning: true,
6+
hideButtons: false,
7+
maxWidth: 650,
8+
9+
initComponent: function(){
10+
Ext4.applyIf(this, {
11+
bodyStyle: 'padding: 5px;',
12+
items: [{
13+
html: 'Loading...',
14+
border: false
15+
}],
16+
buttons: this.hideButtons ? null : SingleCell.panel.TenxSettingsPanel.getButtons()
17+
});
18+
19+
this.callParent(arguments);
20+
21+
LABKEY.Ajax.request({
22+
method: 'POST',
23+
url: LABKEY.ActionURL.buildURL('singlecell', 'getTenXImportDefaults'),
24+
scope: this,
25+
success: this.onDataLoad,
26+
failure: LDK.Utils.getErrorCallback()
27+
});
28+
},
29+
30+
onDataLoad: function(response){
31+
LDK.Utils.decodeHttpResponseJson(response);
32+
this.removeAll();
33+
34+
if (response.responseJSON){
35+
var configDefaults = response.responseJSON;
36+
var items = [{
37+
html: 'Note: you must reload this page before any change will be applied.',
38+
border: false,
39+
hidden: !!this.hidePageLoadWarning
40+
},{
41+
xtype: 'checkbox',
42+
fieldLabel: 'Require Assay Type',
43+
labelWidth: 300,
44+
itemId: 'requireAssayType',
45+
checked: !!JSON.parse(configDefaults.requireAssayType)
46+
},{
47+
xtype: 'checkbox',
48+
fieldLabel: 'Combine Hashing and Cite-Seq',
49+
labelWidth: 300, itemId: 'combineHashingCite',
50+
checked: !!JSON.parse(configDefaults.combineHashingCite)
51+
}];
52+
53+
this.add(items);
54+
}
55+
else {
56+
this.add({html: 'Something went wrong loading saved data'});
57+
}
58+
},
59+
60+
statics: {
61+
getButtons: function () {
62+
return [{
63+
text: 'Submit',
64+
handler: function (btn) {
65+
var win = btn.up('window');
66+
var panel = win ? win.down('singlecell-tenxsettingspanel') : btn.up('singlecell-tenxsettingspanel');
67+
68+
var params = {};
69+
params['requireAssayType'] = panel.down('#requireAssayType').getValue();
70+
params['combineHashingCite'] = panel.down('#combineHashingCite').getValue();
71+
72+
Ext4.Msg.wait('Saving...');
73+
LABKEY.Ajax.request({
74+
method: 'POST',
75+
url: LABKEY.ActionURL.buildURL('singlecell', 'setTenXImportDefaults'),
76+
jsonData: params,
77+
scope: panel,
78+
success: panel.onSuccess,
79+
failure: LDK.Utils.getErrorCallback()
80+
})
81+
}
82+
}];
83+
}
84+
},
85+
86+
onSuccess: function(){
87+
Ext4.Msg.hide();
88+
Ext4.Msg.alert('Success', 'Settings have been saved');
89+
90+
if (this.up('window')){
91+
this.up('window').close();
92+
}
93+
}
94+
});

singlecell/resources/web/singlecell/panel/cDNAImportPanel.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,32 @@ Ext4.define('SingleCell.panel.cDNAImportPanel', {
9696
scope: this,
9797
href: LABKEY.ActionURL.getContextPath() + '/singlecell/exampleData/ImportReadsetTemplate.xlsx'
9898
}]
99-
}, {
99+
},{
100+
xtype: 'ldk-linkbutton',
101+
hidden: !LABKEY.Security.currentUser.isAdmin,
102+
style: 'margin-top: 10px;',
103+
text: 'Set Page Defaults',
104+
itemId: 'copyPrevious',
105+
linkCls: 'labkey-text-link',
106+
scope: this,
107+
handler: function (btn) {
108+
Ext4.create('Ext.window.Window', {
109+
title: 'Set Page Defaults',
110+
items: [{
111+
xtype: 'singlecell-tenxsettingspanel',
112+
border: false,
113+
hidePageLoadWarning: false,
114+
hideButtons: true
115+
}],
116+
buttons: SingleCell.panel.TenxSettingsPanel.getButtons().concat([{
117+
text: 'Cancel',
118+
handler: function (btn) {
119+
btn.up('window').close();
120+
}
121+
}])
122+
}).show();
123+
}
124+
},{
100125
xtype: 'textfield',
101126
style: 'margin-top: 20px;',
102127
fieldLabel: 'Expt Number',

singlecell/src/org/labkey/singlecell/SingleCellController.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.logging.log4j.LogManager;
2222
import org.apache.logging.log4j.Logger;
2323
import org.json.JSONArray;
24+
import org.labkey.api.action.ApiResponse;
2425
import org.labkey.api.action.ApiSimpleResponse;
2526
import org.labkey.api.action.ApiUsageException;
2627
import org.labkey.api.action.ExportAction;
@@ -35,6 +36,7 @@
3536
import org.labkey.api.data.ContainerManager;
3637
import org.labkey.api.data.ContainerType;
3738
import org.labkey.api.data.DbScope;
39+
import org.labkey.api.data.PropertyManager;
3840
import org.labkey.api.data.SimpleFilter;
3941
import org.labkey.api.data.TableInfo;
4042
import org.labkey.api.data.TableSelector;
@@ -47,6 +49,7 @@
4749
import org.labkey.api.query.UserSchema;
4850
import org.labkey.api.security.RequiresPermission;
4951
import org.labkey.api.security.User;
52+
import org.labkey.api.security.permissions.AdminPermission;
5053
import org.labkey.api.security.permissions.InsertPermission;
5154
import org.labkey.api.security.permissions.ReadPermission;
5255
import org.labkey.api.sequenceanalysis.SequenceOutputFile;
@@ -494,4 +497,64 @@ public void addNavTrail(NavTree tree)
494497
}
495498
}
496499

500+
public final static String CONFIG_PROPERTY_DOMAIN_IMPORT = "org.labkey.singlecell.importsettings";
501+
502+
@RequiresPermission(ReadPermission.class)
503+
public static class GetTenXImportDefaultsAction extends ReadOnlyApiAction<Object>
504+
{
505+
@Override
506+
public ApiResponse execute(Object form, BindException errors) throws Exception
507+
{
508+
Container target = getContainer().isWorkbook() ? getContainer().getParent() : getContainer();
509+
Map<String, Object> resultProperties = new HashMap<>(PropertyManager.getProperties(target, CONFIG_PROPERTY_DOMAIN_IMPORT));
510+
511+
return new ApiSimpleResponse(resultProperties);
512+
}
513+
}
514+
515+
@RequiresPermission(AdminPermission.class)
516+
public static class SetTenXImportDefaultsAction extends MutatingApiAction<SetSequenceImportDefaultsForm>
517+
{
518+
public static final String REQUIRE_ASSAY_TYPE = "requireAssayType";
519+
public static final String COMBINE_HASHING_CITE = "combineHashingCite";
520+
521+
@Override
522+
public ApiResponse execute(SetSequenceImportDefaultsForm form, BindException errors) throws Exception
523+
{
524+
Container target = getContainer().isWorkbook() ? getContainer().getParent() : getContainer();
525+
PropertyManager.PropertyMap configMap = PropertyManager.getWritableProperties(target, CONFIG_PROPERTY_DOMAIN_IMPORT, true);
526+
configMap.put(REQUIRE_ASSAY_TYPE, Boolean.valueOf(form.isRequireAssayType()).toString());
527+
configMap.put(COMBINE_HASHING_CITE, Boolean.valueOf(form.isCombineHashingCite()).toString());
528+
529+
configMap.save();
530+
531+
return new ApiSimpleResponse("success", true);
532+
}
533+
}
534+
535+
public static class SetSequenceImportDefaultsForm
536+
{
537+
private boolean _requireAssayType = false;
538+
private boolean _combineHashingCite = false;
539+
540+
public boolean isRequireAssayType()
541+
{
542+
return _requireAssayType;
543+
}
544+
545+
public void setRequireAssayType(boolean requireAssayType)
546+
{
547+
_requireAssayType = requireAssayType;
548+
}
549+
550+
public boolean isCombineHashingCite()
551+
{
552+
return _combineHashingCite;
553+
}
554+
555+
public void setCombineHashingCite(boolean combineHashingCite)
556+
{
557+
_combineHashingCite = combineHashingCite;
558+
}
559+
}
497560
}

0 commit comments

Comments
 (0)