Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions api/src/Page/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ function __get_autoproc_attachments()
array_push($args, $this->arg('FILENAME'));
}

if ($this->has_arg('FILETYPE')) {
if ($this->has_arg('filetype')) {
$where .= ' AND appa.filetype =:' . (sizeof($args) + 1);
array_push($args, $this->arg('FILETYPE'));
array_push($args, $this->arg('filetype'));
}

if ($this->has_arg('AUTOPROCPROGRAMID')) {
Expand Down
32 changes: 32 additions & 0 deletions api/src/Page/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Process extends Page
public static $arg_list = array(
'PROCESSINGJOBID' => '\d+',
'DATACOLLECTIONID' => '\d+',
'SCALINGID' => '\d+',
'DISPLAYNAME' => '([\w\s\-])+',
'COMMENTS' => '.*',

Expand Down Expand Up @@ -45,6 +46,7 @@ class Process extends Page
array('/sweeps', 'post', '_add_reprocessing_sweeps'),

array('/enqueue', 'post', '_enqueue'),
array('/enqueue/downstream', 'post', '_enqueue_downstream'),

array('/pipelines', 'get', '_pipelines'),
);
Expand Down Expand Up @@ -384,6 +386,36 @@ function _enqueue()
$this->_output(new \stdClass);
}

function _enqueue_downstream()
{
if (!$this->has_arg('DATACOLLECTIONID')) $this->_error('No data collection id specified');
if (!$this->has_arg('SCALINGID')) $this->_error('No scaling id specified');
if (!$this->has_arg('RECIPE')) $this->_error('No recipe specified');

$chk = $this->db->pq("SELECT dc.datacollectionid, aps.autoprocscalingid
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
INNER JOIN proposal p ON p.proposalid = s.proposalid
INNER JOIN processingjob rp ON rp.datacollectionid = dc.datacollectionid
INNER JOIN autoprocprogram app ON app.processingjobid = rp.processingjobid
INNER JOIN autoproc ap ON ap.autoprocprogramid = app.autoprocprogramid
INNER JOIN autoprocscaling aps ON aps.autoprocid = ap.autoprocid
WHERE p.proposalid = :1 AND dc.datacollectionid = :2 AND aps.autoprocscalingid = :3",
array($this->proposalid, $this->arg('DATACOLLECTIONID'), $this->arg('SCALINGID')));

if (!sizeof($chk)) $this->_error('No such data collection id or scaling id');

$parameters = array(
'ispyb_dcid' => intval($this->arg('DATACOLLECTIONID')),
'scaling_id' => intval($this->arg('SCALINGID')),
);

$this->_submit_zocalo_recipe($this->arg('RECIPE'), $parameters);

$this->_output(new \stdClass);
}

/*
* Controller method for /process/pipelines
* Returns list of processing pipelines that meet query parameters
Expand Down
2 changes: 2 additions & 0 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ private function _autoprocessing_query_builder($where, $group, $order = '') {
apss.multiplicity,
apss.meanioversigi as isigi,
apss.resioversigi2 as resisigi,
aps.autoprocscalingid,
ap.spacegroup as sg,
ap.refinedcell_a as cell_a,
ap.refinedcell_b as cell_b,
Expand Down Expand Up @@ -1149,6 +1150,7 @@ private function _format_auto_processing_result($table_rows, $messages_result) {

$formatted_result[$row['AUTOPROCPROGRAMID']]['TYPE'] = $row['TYPE'];
$formatted_result[$row['AUTOPROCPROGRAMID']]['AID'] = $row['AUTOPROCPROGRAMID'];
$formatted_result[$row['AUTOPROCPROGRAMID']]['SCALINGID'] = $row['AUTOPROCSCALINGID'];
$formatted_result[$row['AUTOPROCPROGRAMID']]['MESSAGES'] = array_key_exists($row['AUTOPROCPROGRAMID'], $messages_result)
? $messages_result[$row['AUTOPROCPROGRAMID']]
: array();
Expand Down
16 changes: 13 additions & 3 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1714,16 +1714,26 @@ function _proteins()
}


$tot = $this->db->pq("SELECT count(distinct pr.proteinid) as tot FROM protein pr INNER JOIN proposal p ON p.proposalid = pr.proposalid $join WHERE $where", $args);
$tot = intval($tot[0]['TOT']);

if ($this->has_arg('s')) {
$st = sizeof($args) + 1;
$where .= " AND (lower(pr.name) LIKE lower(CONCAT(CONCAT('%',:" . $st . "), '%')) OR lower(pr.acronym) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 1) . "), '%')))";
for ($i = 0; $i < 2; $i++)
array_push($args, $this->arg('s'));
}

if ($this->has_arg('sid')) {
$where .= ' AND b.blsampleid=:' . (sizeof($args) + 1);
array_push($args, $this->arg('sid'));
$join .= ' LEFT JOIN diffractionplan dp ON dp.diffractionplanid = b.diffractionplanid';
$extc = 'dp.anomalousscatterer, ';
}

$tot = $this->db->pq("SELECT count(distinct pr.proteinid) as tot FROM protein pr
INNER JOIN proposal p ON p.proposalid = pr.proposalid
LEFT OUTER JOIN crystal cr ON cr.proteinid = pr.proteinid
LEFT OUTER JOIN blsample b ON b.crystalid = cr.crystalid
$join WHERE $where", $args);
$tot = intval($tot[0]['TOT']);

$start = 0;
$pp = $this->has_arg('per_page') ? $this->arg('per_page') : 15;
Expand Down
10 changes: 10 additions & 0 deletions client/src/js/modules/dc/views/autointegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define(['marionette',
'modules/dc/views/aiplots',
'modules/dc/views/autoprocattachments',
'modules/dc/views/apmessages',
'modules/dc/views/downstream2',

'views/log',
'views/table',
Expand All @@ -16,6 +17,7 @@ define(['marionette',
'templates/dc/dc_autoproc.html'], function(Marionette, Backbone, Backgrid, TabView,
AutoProcAttachments, AutoIntegrations,
RDPlotView, AIPlotsView, AutoProcAttachmentsView, APMessagesView,
DownstreamView,
LogView, TableView, table,
utils, template) {

Expand All @@ -30,6 +32,7 @@ define(['marionette',
'click .rd': 'showRD',
'click .plot': 'showPlots',
'click a.apattach': 'showAttachments',
'click a.downstream': 'downstream',
'click .dll': utils.signHandler,
},

Expand Down Expand Up @@ -57,6 +60,11 @@ define(['marionette',
this.listenTo(this.attachments, 'file:uploaded', this.showAttachments, this)
},

downstream: function(e) {
e.preventDefault()
app.dialog.show(new DownstreamView({ model: this.getOption('templateHelpers').PARENT, scalingid: this.model.get('SCALINGID'), autoprocprogramid: this.model.get('AID'), type: this.model.get('TYPE')}))
},

showLog: function(e) {
e.preventDefault()
var url = $(e.target).attr('href')
Expand Down Expand Up @@ -98,6 +106,7 @@ define(['marionette',
DCID: dcId,
APIURL: app.apiurl,
PROPOSAL_TYPE: app.type,
PARENT: this.options.parent,
}
}
},
Expand Down Expand Up @@ -170,6 +179,7 @@ define(['marionette',
collection: this.collection,
id: this.getOption('id'),
el: this.$el.find('.res'),
parent: this.options.parent,
}))
}

Expand Down
3 changes: 2 additions & 1 deletion client/src/js/modules/dc/views/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ define(['marionette',
this.ap = new DCAutoIntegrationView({
id: this.model.get('ID'),
dcPurgedProcessedData: this.model.get('PURGEDPROCESSEDDATA'),
el: this.$el.find('div.autoproc')
el: this.$el.find('div.autoproc'),
parent: this.model
})
} else this.ap.$el.slideToggle()
},
Expand Down
204 changes: 204 additions & 0 deletions client/src/js/modules/dc/views/downstream2.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a different filename, so that the purpose of this file is a bit more obvious?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the name was to mirror the reprocess2.js file in the same directory, but you're right, better to use something that actually describes it. Have renamed to downstreamreprocess.js.

Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
define(['backbone', 'marionette', 'views/dialog',
'collections/datacollections',
'collections/proteins',
'collections/autoprocattachments',
'models/datacollection',
'modules/mc/views/dcdistl_downstream',
'modules/samples/collections/pdbs',
'utils/kvcollection',
'templates/dc/downstream.html', 'templates/dc/downstream_dc.html'
], function(Backbone, Marionette, DialogView,
DataCollections, Proteins, AutoProcAttachments,
DataCollection, DCDistlView,
PDBs,
KVCollection,
template, dctemplate
) {


var IDDataCollection = DataCollection.extend({
idAttribute: 'CID',
})

var IDDataCollections = DataCollections.extend({
model: IDDataCollection,
})

var DCDistlViewLarge = DCDistlView.extend({
template: dctemplate,
intStatus: false,
className: 'data_collection',

initialize: function(options) {
DCDistlView.prototype.initialize.apply(this, arguments)
},

onRender: function() {
this.$el.find('ul').addClass('half')
this.$el.find('li input[type="text"]').css('width', '25%')
},

})


var DCDistlsView = Marionette.CollectionView.extend({
childView: DCDistlViewLarge,
childViewOptions: function() {
return {
pipelines: this.getOption('pipelines'),
parent: this.model,
}
}
})


var Pipelines = Backbone.Collection.extend(_.extend({
keyAttribute: 'NAME',
valueAttribute: 'VALUE',
}, KVCollection))


return ReprocessView = DialogView.extend({
template: template,
dialog: true,
title: 'Rerun downstream processing',
className: 'rp content',
dOptions: {
width: '1000px',
},

regions: {
dcr: '.dcs',
},

ui: {
pipeline: 'select[name=pipeline]',
warning: '#warning',
},

buttons: {
Submit: 'submit',
Close: 'closeDialog',
},

disabledButtons: {
Close: 'closeDialog',
},

events: {
'change @ui.pipeline': 'updatePipeline',
},

templateHelpers: function() {
return {
VISIT: this.getOption('visit')
}
},

updatePipeline: function() {
this.model.set('PIPELINE', this.ui.pipeline.val())
this.model.set('PIPELINENAME', this.ui.pipeline.find('option:selected').text())
var btns = this.buttons
var warning = ''
if (['MrBUMP', 'Dimple'].includes(this.model.get('PIPELINENAME')) && this.type.includes('autoPROC')) {
warning = ' Cannot rerun ' + this.model.get('PIPELINENAME') + ' on ' + this.type + ' results'
btns = this.disabledButtons
}
if (['MrBUMP', 'Big EP'].includes(this.model.get('PIPELINENAME')) && this.type.includes('fast_dp')) {
warning = ' Cannot rerun ' + this.model.get('PIPELINENAME') + ' on ' + this.type + ' results'
btns = this.disabledButtons
}
if (this.model.get('PIPELINENAME') === 'Dimple' && this.pdbs.length === 0) {
warning = ' Cannot run Dimple as no PDBs defined'
btns = this.disabledButtons
}
if (this.model.get('PIPELINENAME') === 'MrBUMP' && this.model.get('HASSEQ') === 'No') {
warning = ' Cannot run MrBUMP as no sequence defined'
btns = this.disabledButtons
}
if (this.model.get('PIPELINENAME') === 'Fast EP' && (!this.model.get('ANOMALOUSSCATTERER'))) {
warning = ' Cannot run Fast EP as no anomalous scatterer defined'
btns = this.disabledButtons
}
if (this.model.get('PIPELINENAME') === 'Big EP' && this.model.get('HASSEQ') === 'No') {
warning = ' Cannot run Big EP as no sequence defined'
btns = this.disabledButtons
}
if (this.model.get('PIPELINENAME') === 'Big EP' && (!this.model.get('ANOMALOUSSCATTERER'))) {
warning = ' Cannot run Big EP as no anomalous scatterer defined'
btns = this.disabledButtons
}
this.setButtons(btns)
this.ui.warning.html(warning)
},

submit: function(e) {
e.preventDefault()

this._enqueue({ RECIPE: this.model.get('PIPELINE'), DATACOLLECTIONID: this.model.get('ID'), SCALINGID: this.scalingid })
app.message({ message: 'Downstream processing job successfully submitted'})

},


_enqueue: function(options) {
Backbone.ajax({
url: app.apiurl+'/process/enqueue/downstream',
method: 'POST',
data: {
DATACOLLECTIONID: options.DATACOLLECTIONID,
SCALINGID: options.SCALINGID,
RECIPE: options.RECIPE
},
})
},


initialize: function(options) {
this.proteins = new Proteins(null, { queryParams: { sid: options.model.get('BLSAMPLEID') } })
this._ready = this.proteins.fetch()
this._ready.done(this.doOnReady.bind(this))
this.scalingid = options.scalingid
this.type = options.type
this.attachments = new AutoProcAttachments()
this.attachments.queryParams = {
AUTOPROCPROGRAMID: options.autoprocprogramid,
filetype: 'Result',
}
this.attachments.fetch()
},

onRender: function() {

this.pipelines = new Pipelines([
{ NAME: 'Dimple', VALUE: 'trigger-dimple' },
{ NAME: 'Fast EP', VALUE: 'trigger-fastep' },
{ NAME: 'Big EP', VALUE: 'trigger-bigep' },
{ NAME: 'MrBUMP', VALUE: 'trigger-mrbump' },
])

this.ui.pipeline.html(this.pipelines.opts())
},

doOnReady: function() {
var protein = this.proteins.at(0)
var self = this
_.each(['ACRONYM','PROTEINID','HASSEQ','PDBS','ANOMALOUSSCATTERER'], function(k) {
self.model.set(k, protein.get(k))
})
this.pdbs = new PDBs(null, { pid: this.model.get('PROTEINID') })
this.pdbs.fetch().done(this.updatePipeline.bind(this))
this.collection = new IDDataCollections()
if (this.model) {
var nm = new IDDataCollection(this.model.toJSON())
nm.set('CID', this.collection.length+1)
this.collection.add(nm)
}
this.distlview = new DCDistlsView({ collection: this.collection, pipelines: this.pipelines })
this.dcr.show(this.distlview)
}


})

})
Loading
Loading