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
13 changes: 13 additions & 0 deletions PMR/resources/queries/study/exportedDemographics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
d.Id,
d.date,
d.gender,
d.species,
d.geographic_origin,
d.birth,
d.death,
d.calculated_status,
d.Id.parents.dam as dam,
d.Id.parents.sire as sire

FROM study.demographics d
12 changes: 12 additions & 0 deletions PMR/resources/schemas/PMR_Data.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<templateSchema sourceSchemaName="study" xmlns="http://labkey.org/data/xml/externalSchema" xmlns:cv="http://labkey.org/data/xml/queryCustomView">
<tables>
<tableName>exportedDemographics</tableName>
</tables>
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="exportedDemographics" tableDbType="NOT_IN_DB">
<tableTitle>Demographics</tableTitle>
</table>
</tables>
</metadata>
</templateSchema>
10 changes: 5 additions & 5 deletions mGAP/resources/queries/mGAP/subjectsSource.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ SELECT
d.status as status,
m.subjectname as originalId,
p1.externalAlias as sire,
coalesce(s.Id.parents.sire, d.sire) as originalSire,
coalesce(s.sire, d.sire) as originalSire,
p2.externalAlias as dam,
coalesce(s.Id.parents.dam, d.dam) as originalDam,
coalesce(s.dam, d.dam) as originalDam,

FROM mgap.animalMapping m
LEFT JOIN "/Internal/PMR/".study.demographics s ON (m.subjectname = s.Id)
LEFT JOIN PMR_Data.exportedDemographics s ON (m.subjectname = s.Id)
LEFT JOIN mgap.demographics d ON (m.subjectname = d.subjectname)
LEFT JOIN mgap.animalMapping p1 ON (p1.subjectname = coalesce(s.Id.parents.sire, d.sire))
LEFT JOIN mgap.animalMapping p2 ON (p2.subjectname = coalesce(s.Id.parents.dam, d.dam))
LEFT JOIN mgap.animalMapping p1 ON (p1.subjectname = coalesce(s.sire, d.sire))
LEFT JOIN mgap.animalMapping p2 ON (p2.subjectname = coalesce(s.dam, d.dam))
WHERE (s.Id IS NOT NULL OR d.subjectname IS NOT NULL)
6 changes: 6 additions & 0 deletions mGAP/resources/schemas/mGAP_Data.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<templateSchema sourceSchemaName="mGAP" xmlns="http://labkey.org/data/xml/externalSchema" xmlns:cv="http://labkey.org/data/xml/queryCustomView">
<tables>
<tableName>subjectsSource</tableName>
<tableName>sequenceDatasetsSource</tableName>
</tables>
</templateSchema>
Loading