Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions GenotypeAssays/resources/views/bulkHaplotype.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script type="text/javascript" nonce="<%=scriptNonce%>">

Ext4.onReady(function () {
var analysisIds = LABKEY.ActionURL.getParameter('analysisIds');
var analysisId = LABKEY.ActionURL.getParameter('analysisId');

if (!analysisIds) {
alert('Must Provide At Least One Analysis Id');
if (!analysisId) {
alert('Must Provide An Analysis Id');
return;
}

Expand All @@ -15,7 +15,7 @@
title: 'Haplotype Matches',
items: [{
xtype: 'genotypeassays-haplotypepanel',
analysisIds: analysisIds.split(';'),
analysisIds: analysisId,
showCheckBoxes: true
}]
}).render(webpart.wrapperDivId);
Expand Down
14 changes: 9 additions & 5 deletions GenotypeAssays/resources/views/sbtReview.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@
allowHeaderLock: false,
schemaName: 'sequenceanalysis',
queryName: 'alignment_summary_grouped',
//viewName: 'With Haplotype Matches',
viewName: 'With Haplotype Matches',
//sort: '-percent',
containerPath: Laboratory.Utils.getQueryContainerPath(),
filterArray: [LABKEY.Filter.create('analysis_id', analysisId, LABKEY.Filter.Types.EQUAL)],
removeableFilters: [
LABKEY.Filter.create('percent_from_locus', 0.25, LABKEY.Filter.Types.GTE)
],
parameters: {
AnalysisId: analysisId
},
scope: this,
success: this.onDataRegionLoad
})
Expand All @@ -173,15 +175,17 @@
allowHeaderLock: false,
schemaName: 'sequenceanalysis',
queryName: 'alignment_summary_by_lineage',
//viewName: 'With Haplotype Matches',
viewName: 'With Haplotype Matches',
sort: '-percent',
containerPath: Laboratory.Utils.getQueryContainerPath(),
filterArray: [LABKEY.Filter.create('analysis_id', analysisId, LABKEY.Filter.Types.EQUAL)],
removeableFilters: [
LABKEY.Filter.create('percent_from_locus', 0.25, LABKEY.Filter.Types.GTE),
LABKEY.Filter.create('total_reads', 5, LABKEY.Filter.Types.GT),
LABKEY.Filter.create('totalLineages', 1, LABKEY.Filter.Types.EQUAL)
],
parameters: {
AnalysisId: analysisId
},
scope: this,
success: this.onDataRegionLoad
})
Expand All @@ -191,7 +195,7 @@
title: 'Haplotype Matches',
items: [{
xtype: 'genotypeassays-haplotypepanel',
analysisIds: [analysisId]
analysisId: [analysisId]
}]
},{
xtype: 'ldk-querypanel',
Expand Down
7 changes: 6 additions & 1 deletion GenotypeAssays/resources/web/genotypeassays/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ GenotypeAssays.buttons = new function(){
return;
}

if (checked.length !== 1) {
alert('Only one row at a time can be selected');
return;
}

var newForm = Ext4.DomHelper.append(document.getElementsByTagName('body')[0],
'<form method="POST" action="' + LABKEY.ActionURL.buildURL("genotypeassays", "bulkHaplotype", null) + '">' +
'<input type="hidden" name="analysisIds" value="' + Ext4.htmlEncode(checked.join(';')) + '" />' +
'<input type="hidden" name="analysisId" value="' + Ext4.htmlEncode(checked[0]) + '" />' +
'</form>');
newForm.submit();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Ext4.define('GenotypeAssays.panel.HaplotypePanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.genotypeassays-haplotypepanel',
analysisIds: null,
analysisId: null,
showCheckBoxes: false,

initComponent: function(){
Expand Down Expand Up @@ -266,10 +266,11 @@ Ext4.define('GenotypeAssays.panel.HaplotypePanel', {
}
}, this);

Ext4.Msg.confirm('Publish Selected?', 'You have chosen to published the following haplotypes:<br><br>' + (haplotypeNames.length > 8 ? 'Too many to display' : haplotypeNames.join('<br>')) + '<br><br>Continue?', function (val) {
Ext4.Msg.confirm('Publish Selected?', 'You have chosen to publish the following haplotypes:<br><br>' + (haplotypeNames.length > 8 ? 'Too many to display' : haplotypeNames.join('<br>')) + '<br><br>Continue?', function (val) {
if (val == 'yes') {
Ext4.create('GenotypeAssays.window.PublishResultsWindow', {
actionName: 'cacheHaplotypes',
analysisId: this.analysisId,
json: json
}).show();
}
Expand Down Expand Up @@ -460,10 +461,12 @@ Ext4.define('GenotypeAssays.panel.HaplotypePanel', {
schemaName: 'sequenceanalysis',
queryName: 'alignment_summary_by_lineage',
columns: 'analysis_id,analysis_id/readset,analysis_id/readset/subjectId,lineages,loci,total,total_reads,percent,total_reads_from_locus,percent_from_locus',
parameters: {
AnalysisId: this.analysisId
},
apiVersion: 13.2,
scope: this,
filterArray: [
LABKEY.Filter.create('analysis_id', this.analysisIds.join(';'), LABKEY.Filter.Types.IN),
LABKEY.Filter.create('percent_from_locus', minPct || 0, LABKEY.Filter.Types.GTE)
],
failure: LDK.Utils.getErrorCallback(),
Expand Down Expand Up @@ -502,9 +505,9 @@ Ext4.define('GenotypeAssays.panel.HaplotypePanel', {
sort: 'analysis_id',
apiVersion: 13.2,
scope: this,
filterArray: [
LABKEY.Filter.create('analysis_id', this.analysisIds.join(';'), LABKEY.Filter.Types.IN)
],
parameters: {
AnalysisId: this.analysisId
},
failure: LDK.Utils.getErrorCallback(),
success: function(results){
this.lineageToAlleleMap = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,20 @@ Ext4.define('GenotypeAssays.window.PublishResultsWindow', {
return;
}

const analysisId = dr.getParameters()?.AnalysisId;
if (!analysisId) {
Ext4.Msg.alert('Error', 'Error: unable to find analysisId. This should not occur.');
LDK.Assert.assertNotEmpty('Unable to find AnalysisId parameter from the DataRegion in PublishResultsWindow');

return;
}

Ext4.create('GenotypeAssays.window.PublishResultsWindow', {
dataRegionName: dataRegionName,
analysisId: analysisId,
actionName: 'cacheAnalyses'
}).show();
}

// haplotypeButtonHandler: function(dataRegionName){
// var dr = LABKEY.DataRegions[dataRegionName];
// LDK.Assert.assertNotEmpty('Unable to find dataregion in PublishResultsWindow', dr);
//
// if (!dr.getChecked().length) {
// Ext4.Msg.alert('Error', 'No rows selected');
// return;
// }
//
// Ext4.create('GenotypeAssays.window.PublishResultsWindow', {
// dataRegionName: dataRegionName,
// actionName: 'cacheHaplotypes'
// }).show();
// }
},

initComponent: function(){
Expand Down Expand Up @@ -122,6 +116,7 @@ Ext4.define('GenotypeAssays.window.PublishResultsWindow', {
scope: this,
jsonData: {
alleleNames: alleleNames,
analysisId: this.analysisId,
json: Ext4.encode(this.json),
protocolId: protocol
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
}

String[] alleleNames = Arrays.stream(form.getAlleleNames()).map(StringEscapeUtils::unescapeHtml4).toArray(String[]::new);
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, alleleNames);
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), form.getAnalysisId(), protocol, alleleNames);
resultProperties.put("runsCreated", ret.first);
resultProperties.put("runsDeleted", ret.second);
}
Expand All @@ -159,6 +159,7 @@ public static class CacheAnalysesForm
{
private String[] _alleleNames;
private String _json;
private int _analysisId;
private int _protocolId;

public String[] getAlleleNames()
Expand Down Expand Up @@ -190,6 +191,16 @@ public void setJson(String json)
{
_json = json;
}

public int getAnalysisId()
{
return _analysisId;
}

public void setAnalysisId(int analysisId)
{
_analysisId = analysisId;
}
}

@RequiresPermission(UpdatePermission.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public static GenotypeAssaysManager get()
return _instance;
}


public Pair<List<Long>, List<Long>> cacheAnalyses(final ViewContext ctx, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
public Pair<List<Long>, List<Long>> cacheAnalyses(final ViewContext ctx, final int analysisId, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
{
final User u = ctx.getUser();
final List<Long> runsCreated = new ArrayList<>();
Expand Down Expand Up @@ -126,6 +125,8 @@ public Pair<List<Long>, List<Long>> cacheAnalyses(final ViewContext ctx, final E

AtomicInteger records = new AtomicInteger();
TableSelector tsAlignments = new TableSelector(tableAlignments, cols.values(), new SimpleFilter(FieldKey.fromString("key"), Arrays.asList(pks), CompareType.IN), null);
tsAlignments.setNamedParameters(Map.of("AnalysisId", analysisId));

tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ private void processAnalysis(int analysisId)
final Map<String, Double> existingData = new HashMap<>();
SimpleFilter dataFilter = new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId, CompareType.EQUAL);
dataFilter.addCondition(FieldKey.fromString("percent_from_locus"), getPipelineJob().getLineageThreshold(), CompareType.GT);
new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("lineages", "percent_from_locus"), dataFilter, null).forEachResults(rs -> {

TableSelector ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("lineages", "percent_from_locus"), dataFilter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));

ts.forEachResults(rs -> {
existingData.put(rs.getString(FieldKey.fromString("lineages")), rs.getDouble(FieldKey.fromString("percent_from_locus")));
});

Expand Down Expand Up @@ -311,7 +315,10 @@ private void processAnalysis(int analysisId)
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId, CompareType.EQUAL);
filter.addCondition(FieldKey.fromString("percent_from_locus"), getPipelineJob().getLineageThreshold(), CompareType.LT);

List<String> lowFreqRowIdList = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("rowids"), filter, null).getArrayList(String.class);
ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("rowids"), filter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));

List<String> lowFreqRowIdList = ts.getArrayList(String.class);
if (!lowFreqRowIdList.isEmpty())
{
getJob().getLogger().info("Analysis: " + analysisId + ", low freq lineages: " + lowFreqRowIdList.size());
Expand All @@ -329,7 +336,9 @@ private void processAnalysis(int analysisId)
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId, CompareType.EQUAL);
filter.addCondition(FieldKey.fromString("percent_from_locus"), getPipelineJob().getAlleleGroupThreshold(), CompareType.LT);

List<String> lowFreqRowIdList = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), filter, null).getArrayList(String.class);
ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), filter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));
List<String> lowFreqRowIdList = ts.getArrayList(String.class);
if (!lowFreqRowIdList.isEmpty())
{
getJob().getLogger().info("Analysis: " + analysisId + ", low freq allele groups: " + lowFreqRowIdList.size());
Expand Down Expand Up @@ -363,7 +372,9 @@ private void processAnalysis(int analysisId)
filter.addCondition(FieldKey.fromString("totalLineages"), 1, CompareType.GT);
filter.addCondition(FieldKey.fromString("loci"), "MHC", CompareType.CONTAINS);

List<String> rowIdList = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), filter, null).getArrayList(String.class);
ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), filter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));
List<String> rowIdList = ts.getArrayList(String.class);
if (!rowIdList.isEmpty())
{
getJob().getLogger().info("Analysis: " + analysisId + ", multi-lineage records: " + rowIdList.size());
Expand All @@ -380,7 +391,9 @@ private void processAnalysis(int analysisId)
{
SimpleFilter nAlignmentFilter = new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId, CompareType.EQUAL);
nAlignmentFilter.addCondition(FieldKey.fromString("nAlignments"), 1, CompareType.GT);
List<String> redundantAlignmentSets = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), nAlignmentFilter, null).getArrayList(String.class);
ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("rowids"), nAlignmentFilter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));
List<String> redundantAlignmentSets = ts.getArrayList(String.class);
if (!redundantAlignmentSets.isEmpty())
{
getJob().getLogger().info("Analysis: " + analysisId + ", redundant alignment sets: " + redundantAlignmentSets.size());
Expand Down Expand Up @@ -446,7 +459,9 @@ private void processAnalysis(int analysisId)

// verify ending data:
final Map<String, Double> endingData = new HashMap<>();
new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("lineages", "percent_from_locus"), dataFilter, null).forEachResults(rs -> {
ts = new TableSelector(QueryService.get().getUserSchema(getJob().getUser(), getJob().getContainer(), "sequenceanalysis").getTable("alignment_summary_by_lineage"), PageFlowUtil.set("lineages", "percent_from_locus"), dataFilter, null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));
ts.forEachResults(rs -> {
endingData.put(rs.getString(FieldKey.fromString("lineages")), rs.getDouble(FieldKey.fromString("percent_from_locus")));
});

Expand Down Expand Up @@ -515,7 +530,9 @@ public AlignmentGroupCompare(final int analysisId, Container c, User u)
{
this.analysisId = analysisId;

new TableSelector(QueryService.get().getUserSchema(u, c, "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("analysis_id", "alleles", "lineages", "totalLineages", "total_reads", "total_forward", "total_reverse", "valid_pairs", "rowids"), new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId), null).forEachResults(rs -> {
TableSelector ts = new TableSelector(QueryService.get().getUserSchema(u, c, "sequenceanalysis").getTable("alignment_summary_grouped"), PageFlowUtil.set("analysis_id", "alleles", "lineages", "totalLineages", "total_reads", "total_forward", "total_reverse", "valid_pairs", "rowids"), new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId), null);
ts.setNamedParameters(Map.of("AnalysisId", analysisId));
ts.forEachResults(rs -> {
if (rs.getString(FieldKey.fromString("alleles")) == null)
{
return;
Expand Down