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
16 changes: 6 additions & 10 deletions GenotypeAssays/resources/views/sbtReview.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@
//sort: '-percent',
containerPath: Laboratory.Utils.getQueryContainerPath(),
removeableFilters: [
LABKEY.Filter.create('percent_from_locus', 0.25, LABKEY.Filter.Types.GTE)
LABKEY.Filter.create('percent_from_locus', 0.25, LABKEY.Filter.Types.GTE),
LABKEY.Filter.create('analysis_id', analysisId, LABKEY.Filter.Types.EQUALS)
],
parameters: {
AnalysisId: analysisId
},
scope: this,
success: this.onDataRegionLoad
})
Expand All @@ -180,12 +178,10 @@
containerPath: Laboratory.Utils.getQueryContainerPath(),
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)
LABKEY.Filter.create('total_reads_from_locus', 5, LABKEY.Filter.Types.GT),
LABKEY.Filter.create('totalLineages', 1, LABKEY.Filter.Types.EQUAL),
LABKEY.Filter.create('analysis_id', analysisId, LABKEY.Filter.Types.EQUAL)
],
parameters: {
AnalysisId: analysisId
},
scope: this,
success: this.onDataRegionLoad
})
Expand All @@ -195,7 +191,7 @@
title: 'Haplotype Matches',
items: [{
xtype: 'genotypeassays-haplotypepanel',
analysisId: [analysisId]
analysisIds: [analysisId]
}]
},{
xtype: 'ldk-querypanel',
Expand Down
2 changes: 1 addition & 1 deletion GenotypeAssays/resources/web/genotypeassays/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GenotypeAssays.buttons = new function(){

var newForm = Ext4.DomHelper.append(document.getElementsByTagName('body')[0],
'<form method="POST" action="' + LABKEY.ActionURL.buildURL("genotypeassays", "bulkHaplotype", null) + '">' +
'<input type="hidden" name="analysisId" value="' + Ext4.htmlEncode(checked[0]) + '" />' +
'<input type="hidden" name="analysisIds" value="' + Ext4.htmlEncode(checked.join(';')) + '" />' +
'</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',
analysisId: null,
analysisIds: null,
showCheckBoxes: false,

initComponent: function(){
Expand Down Expand Up @@ -461,13 +461,11 @@ 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('percent_from_locus', minPct || 0, LABKEY.Filter.Types.GTE)
LABKEY.Filter.create('percent_from_locus', minPct || 0, LABKEY.Filter.Types.GTE),
LABKEY.Filter.create('analysis_id', this.analysisIds, LABKEY.Filter.Types.IN)
],
failure: LDK.Utils.getErrorCallback(),
success: function(results){
Expand Down Expand Up @@ -501,13 +499,13 @@ Ext4.define('GenotypeAssays.panel.HaplotypePanel', {
schemaName: 'sequenceanalysis',
queryName: 'alignment_summary_grouped',
columns: 'analysis_id,lineages,loci,alleles,total_reads,percent,total_reads_from_locus,percent_from_locus',
filterArray: [
LABKEY.Filter.create('analysis_id', this.analysisIds, LABKEY.Filter.Types.IN)
],
// This is designed to remove the view-level sorts:
sort: 'analysis_id',
apiVersion: 13.2,
scope: this,
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,17 +11,8 @@ 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();
}
Expand Down Expand Up @@ -116,7 +107,6 @@ 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 @@ -24,13 +24,15 @@
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.DbSchemaType;
import org.labkey.api.data.SqlExecutor;
import org.labkey.api.data.TableInfo;
import org.labkey.api.exp.api.ExpProtocol;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.security.RequiresPermission;
import org.labkey.api.security.permissions.ReadPermission;
import org.labkey.api.security.permissions.UpdatePermission;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.Pair;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.HtmlView;
Expand All @@ -53,7 +55,7 @@ public GenotypeAssaysController()
}

@RequiresPermission(ReadPermission.class)
public class MigrateLegacySSPAction extends ConfirmAction<Object>
public static class MigrateLegacySSPAction extends ConfirmAction<Object>
{
@Override
public void validateCommand(Object form, Errors errors)
Expand All @@ -64,19 +66,19 @@ public void validateCommand(Object form, Errors errors)
@Override
public ModelAndView getConfirmView(Object form, BindException errors) throws Exception
{
DbSchema schema = DbSchema.get("SSP_Assay");
DbSchema schema = DbSchema.get("SSP_Assay", DbSchemaType.Module);
if (schema == null)
return new HtmlView("Either the legacy SSP module has not been installed, or it has already been removed");
return new HtmlView(HtmlString.of("Either the legacy SSP module has not been installed, or it has already been removed"));
else
return new HtmlView("This allows an admin to copy any primers stored in the original SSP Assay module into the new genotyping module. Any data has already been copied. Do you want to continue?");
return new HtmlView(HtmlString.of("This allows an admin to copy any primers stored in the original SSP Assay module into the new genotyping module. Any data has already been copied. Do you want to continue?"));
}

@Override
public boolean handlePost(Object form, BindException errors) throws Exception
{
try
{
DbSchema schema = DbSchema.get("SSP_Assay");
DbSchema schema = DbSchema.get("SSP_Assay", DbSchemaType.Module);
if (schema == null)
return true; //module not installed

Expand Down Expand Up @@ -113,7 +115,7 @@ public URLHelper getSuccessURL(Object form)
}

@RequiresPermission(UpdatePermission.class)
public class CacheAnalysesAction extends MutatingApiAction<CacheAnalysesForm>
public static class CacheAnalysesAction extends MutatingApiAction<CacheAnalysesForm>
{
@Override
public ApiResponse execute(CacheAnalysesForm form, BindException errors)
Expand All @@ -133,7 +135,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(), form.getAnalysisId(), protocol, alleleNames);
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, alleleNames);
resultProperties.put("runsCreated", ret.first);
resultProperties.put("runsDeleted", ret.second);
}
Expand All @@ -159,7 +161,6 @@ public static class CacheAnalysesForm
{
private String[] _alleleNames;
private String _json;
private int _analysisId;
private int _protocolId;

public String[] getAlleleNames()
Expand Down Expand Up @@ -191,20 +192,10 @@ public void setJson(String json)
{
_json = json;
}

public int getAnalysisId()
{
return _analysisId;
}

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

@RequiresPermission(UpdatePermission.class)
public class CacheHaplotypesAction extends MutatingApiAction<CacheAnalysesForm>
public static class CacheHaplotypesAction extends MutatingApiAction<CacheAnalysesForm>
{
@Override
public ApiResponse execute(CacheAnalysesForm form, BindException errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static GenotypeAssaysManager get()
return _instance;
}

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

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>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ private void processAnalysis(int analysisId)
dataFilter.addCondition(FieldKey.fromString("percent_from_locus"), getPipelineJob().getLineageThreshold(), CompareType.GT);

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 @@ -337,7 +336,6 @@ private void processAnalysis(int analysisId)
filter.addCondition(FieldKey.fromString("percent_from_locus"), getPipelineJob().getAlleleGroupThreshold(), CompareType.LT);

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())
{
Expand Down Expand Up @@ -373,7 +371,6 @@ private void processAnalysis(int analysisId)
filter.addCondition(FieldKey.fromString("loci"), "MHC", CompareType.CONTAINS);

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())
{
Expand All @@ -392,7 +389,6 @@ private void processAnalysis(int analysisId)
SimpleFilter nAlignmentFilter = new SimpleFilter(FieldKey.fromString("analysis_id"), analysisId, CompareType.EQUAL);
nAlignmentFilter.addCondition(FieldKey.fromString("nAlignments"), 1, CompareType.GT);
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())
{
Expand Down Expand Up @@ -460,7 +456,6 @@ private void processAnalysis(int analysisId)
// verify ending data:
final Map<String, Double> endingData = new HashMap<>();
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 @@ -531,7 +526,6 @@ public AlignmentGroupCompare(final int analysisId, Container c, User u)
this.analysisId = analysisId;

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)
{
Expand Down