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
1 change: 1 addition & 0 deletions api/src/Database/Type/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class MySQL extends DatabaseParent {
'DewarReport',
'CourierTermsAccepted',

'BLSamplePosition',
'BLSubSample',
'PDB',
'Protein_has_PDB',
Expand Down
73 changes: 73 additions & 0 deletions api/src/Downstream/Type/LigandFit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace SynchWeb\Downstream\Type;

use SynchWeb\Downstream\DownstreamPlugin;
use SynchWeb\Downstream\DownstreamResult;

class LigandFit extends DownstreamPlugin {
var $has_images = true;
var $friendlyname = 'LigandFit';
var $has_mapmodel = array(1, 0);

function _get_ligandfit_results_json() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filePath, app.filename from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.json' ",
$appid
);
return $filepath;
}

function _get_ligandfit_results_png() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filepath, app.filename from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.png' ",
$appid
);
return $filepath;
}

function _get_model_appaid() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.autoprocprogramattachmentid from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.html' ",
$appid
);
if (sizeof($filepath)) {
return $filepath[0]["AUTOPROCPROGRAMATTACHMENTID"];
} else {
return;
}
}

function results() {
$json_filepath = $this->_get_ligandfit_results_json();
if (sizeof($json_filepath)) {
$json_path = $json_filepath[0]["FILEPATH"] . "/" . $json_filepath[0]["FILENAME"] ;
$json_data = file_get_contents($json_path);
} else {
$json_data = "[]";
}
$dat = array();
$appaid = $this->_get_model_appaid();
$dat['BLOBS'] = $appaid ? 1 : 0;
$dat['MODEL_APPAID'] = $appaid;
$dat['SOLUTIONS'] = json_decode($json_data);
$dat['PARENTAUTOPROCPROGRAM'] = $this->process['PROCESSINGCOMMENTS'];

$results = new DownstreamResult($this);
$results->data = $dat;

return $results;
}

function images($n = 0) {
$png = $this->_get_ligandfit_results_png();
if (sizeof($png)) {
return $png[0]["FILEPATH"] . "/" . $png[0]["FILENAME"];
} else {
return;
}
}
}
6 changes: 5 additions & 1 deletion api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DC extends Page
'PERSONID' => '\d+',
'AUTOPROCPROGRAMMESSAGEID' => '\d+',
'PROCESSINGJOBID' => '\d+',
'expandgroups' => '\d',
'debug' => '\d',
'sgid' => '\d+'
);
Expand Down Expand Up @@ -381,7 +382,7 @@ function _data_collections($single = null)
}

# Set Count field
if ($this->has_arg('dcg') || $this->has_arg('PROCESSINGJOBID') || $this->has_arg('sgid')) {
if ($this->has_arg('dcg') || $this->has_arg('PROCESSINGJOBID') || $this->has_arg('sgid') || $this->has_arg('expandgroups')) {
$count_field = 'dc.datacollectionid';
} else {
$count_field = 'distinct dc.datacollectiongroupid';
Expand Down Expand Up @@ -616,6 +617,9 @@ function _data_collections($single = null)
IFNULL(max(dc.rotationaxis), 'Omega') as rotationaxis,
dc.detector2theta";
$groupby = "GROUP BY dc.datacollectiongroupid";
if ($this->has_arg('expandgroups')) {
$groupby = "GROUP BY dc.datacollectionid";
}
}

// We don't want to remove duplicates, since if two counts are equal, one might go uncounted
Expand Down
4 changes: 4 additions & 0 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ private function _autoprocessing_query_builder($where, $group, $order = '') {
(SELECT COUNT(api1.autoprocintegrationid) FROM autoprocintegration api1 WHERE api1.autoprocprogramid = app.autoprocprogramid) as imagesweepcount,
app.processingstatus,
app.processingmessage,
app.processingenvironment,
count(distinct pjis.datacollectionid) as dccount,
max(pjis.processingjobid) as processingjobid,
(SELECT IFNULL(blsg.name, bls.name) FROM processingjobparameter pjp
Expand Down Expand Up @@ -1059,6 +1060,9 @@ private function _format_auto_processing_result($table_rows, $messages_result) {
if ($row['GROUPNAME']) {
$value .= ' ('.$row['GROUPNAME'].')';
}
if ($row['PROCESSINGENVIRONMENT'] && strpos($row['PROCESSINGENVIRONMENT'], 'cluster=') !== false) {
$value .= ' ('.$row['PROCESSINGENVIRONMENT'].')';
}
}


Expand Down
6 changes: 5 additions & 1 deletion api/src/Page/Proposal.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ function _get_visits($visit = null, $output = true)
}

if ($this->has_arg('ty')) {
$beamlines = $this->_get_beamlines_from_type($this->arg('ty'));
if ($this->arg('ty') == 'calendar') {
$beamlines = $this->_get_beamlines_from_type($this->ty);
} else {
$beamlines = $this->_get_beamlines_from_type($this->arg('ty'));
}

if (!empty($beamlines)) {
$bls = implode("', '", $beamlines);
Expand Down
40 changes: 36 additions & 4 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class Sample extends Page
'scid' => '\d+-\d+',

'BLSAMPLEID' => '\d+',
'X' => '\d+(.\d+)?',
'Y' => '\d+(.\d+)?',
'X' => '\d*(.\d+)?',
'Y' => '\d*(.\d+)?',
'Z' => '\d+(.\d+)?',
'X2' => '\d+(.\d+)?',
'Y2' => '\d+(.\d+)?',
Expand Down Expand Up @@ -799,6 +799,9 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
po2.posx as x2,
po2.posy as y2,
po2.posz as z2,
bsp.posx as dispensex,
bsp.posy as dispensey,
bsp.posz as dispensez,
IF(cqs.containerqueuesampleid IS NOT NULL AND cqs.containerqueueid IS NULL, 1, 0) as readyforqueue,
cq.containerqueueid,
count(distinct IF(dc.overlap != 0,
Expand All @@ -824,7 +827,7 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
INNER JOIN shipping sh ON sh.shippingid = d.shippingid
INNER JOIN proposal p ON p.proposalid = sh.proposalid


LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = s.blsampleid
LEFT OUTER JOIN containerqueuesample cqs ON cqs.blsubsampleid = ss.blsubsampleid
LEFT OUTER JOIN containerqueue cq ON cqs.containerqueueid = cq.containerqueueid AND cq.completedtimestamp IS NULL

Expand Down Expand Up @@ -1903,11 +1906,12 @@ function _update_sample()
if (!$this->has_arg('sid'))
$this->_error('No sampleid specified');

$samp = $this->db->pq("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid
$samp = $this->db->pq("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid,bsp.blsamplepositionid
FROM blsample b
INNER JOIN crystal cr ON cr.crystalid = b.crystalid
INNER JOIN protein pr ON pr.proteinid = cr.proteinid
LEFT OUTER JOIN diffractionplan dp on dp.diffractionplanid = b.diffractionplanid
LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = b.blsampleid AND bsp.positiontype='dispensing'
WHERE pr.proposalid = :1 AND b.blsampleid = :2", array($this->proposalid, $this->arg('sid')));

if (!sizeof($samp))
Expand Down Expand Up @@ -1980,6 +1984,34 @@ function _update_sample()
}
}
}

if ($this->has_arg('X') && $this->has_arg('Y')) {
$z = $this->has_arg('Z') ? $this->arg('Z') : null;
$pid = $samp['BLSAMPLEPOSITIONID'];
if ($this->arg('X') == '' && $this->arg('Y') == '') {
if (!empty($pid)) {
$this->db->pq(
"UPDATE blsampleposition SET posx=null, posy=null, posz=null, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:1",
array($pid)
);
}
} else {
if (empty($pid)) {
$this->db->pq(
"INSERT INTO blsampleposition (blsampleid, posx, posy, posz, positiontype, recordtimestamp)
VALUES (:1, :2, :3, :4, 'dispensing', CURRENT_TIMESTAMP) RETURNING blsamplepositionid INTO :id",
array($this->arg('sid'), $this->arg('X'), $this->arg('Y'), $z)
);
$pid = $this->db->id();
} else {
$this->db->pq(
"UPDATE blsampleposition SET posx=:1, posy=:2, posz=:3, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:4",
array($this->arg('X'), $this->arg('Y'), $z, $pid)
);
}
}
$this->_output(array('BLSAMPLEPOSITIONID' => $pid));
}
}


Expand Down
6 changes: 5 additions & 1 deletion api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,11 @@ function _get_dewars()
}

if ($this->has_arg('ty')) {
$bls_tmp = $this->_get_beamlines_from_type($this->arg('ty'));
if ($this->arg('ty') == 'overview') {
$bls_tmp = $this->_get_beamlines_from_type($this->ty);
} else {
$bls_tmp = $this->_get_beamlines_from_type($this->arg('ty'));
}
if (!empty($bls_tmp)) {
$bls = implode("', '", $bls_tmp);
$where .= " AND se.beamlinename IN ('$bls')";
Expand Down
5 changes: 5 additions & 0 deletions client/src/css/partials/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,11 @@ li:last-child .visit_users {
width: 40.5%;
height: 300px;

&.map {
width: 30%;
height: auto;
}

&.image-third {
width: 32.4%;

Expand Down
20 changes: 19 additions & 1 deletion client/src/js/models/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ define(['backbone', 'collections/components',
this.listenTo(this, 'change:RADIATIONSENSITIVITY', this.updateRadSen)
this.updateRadSen()

this.listenTo(this, 'change:X', this.updatePosition)

this.listenTo(this, 'change', this.updateHasData)
this.updateHasData()

},

updatePosition: function() {
this.save(this.changedAttributes(), { patch: true })
},

updateHasData: function() {
var hasData = this.get('DC') > 0 || this.get('GR') > 0 || this.get('SC') > 0
if (hasData !== this.get('HASDATA')) this.set('HASDATA', hasData)
Expand Down Expand Up @@ -98,7 +104,10 @@ define(['backbone', 'collections/components',
VOLUME: '',
INITIALSAMPLEGROUP: '',
COMPONENTIDS: [],
COMPONENTAMOUNTS: []
COMPONENTAMOUNTS: [],
X: null,
Y: null,
Z: null,
},

validation: {
Expand Down Expand Up @@ -225,6 +234,15 @@ define(['backbone', 'collections/components',
required: false,
pattern: 'word'
},
X: {
required: false
},
Y: {
required: false
},
Z: {
required: false
},

COMPONENTAMOUNTS: function(from_ui, attr, all_values) {
var values = all_values.components.pluck('ABUNDANCE')
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/calendar/views/calendar-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default {
all: 1,
}
if (app.staff) queryParams.ty = this.proposalType
if (app.staff) queryParams.ty = 'calendar'
if (this.selectedBeamline !== 'all') queryParams.bl = this.selectedBeamline
const visitsCollection = new Visits(null, {
Expand Down
5 changes: 4 additions & 1 deletion client/src/js/modules/dc/views/downstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ define(['backbone', 'marionette',
'modules/dc/views/mrbump',
'modules/dc/views/bigep',
'modules/dc/views/shelxt',
'modules/dc/views/ligandfit',
'templates/dc/downstreamerror.html'

], function(Backbone, Marionette, TabView, DownStreams, DownstreamWrapper,
TableView,
FastEP, DIMPLE, MrBUMP, BigEP, Shelxt, downstreamerror) {
FastEP, DIMPLE, MrBUMP, BigEP, Shelxt, LigandFit, downstreamerror) {

var dcPurgedProcessedData = "0"; // dataCollection.PURGEDPROCESSEDDATA via options from DC.js

Expand Down Expand Up @@ -65,6 +66,7 @@ define(['backbone', 'marionette',
'Crank2': BigEP,
'AutoSHARP': BigEP,
'Shelxt': Shelxt,
'LigandFit': LigandFit,
}

if (model.get('PROCESS').PROCESSINGSTATUS != 1) {
Expand Down Expand Up @@ -125,6 +127,7 @@ define(['backbone', 'marionette',
holderWidth: this.getOption('holderWidth'),
downstreams: this.getOption('downstreams'),
DCID: this.getOption('id'),
mapButton: this.getOption('mapButton'),
}
},

Expand Down
17 changes: 11 additions & 6 deletions client/src/js/modules/dc/views/downstreamwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,12 @@ define(['backbone', 'marionette',
this.messages.show(new APMessagesView({
messages: new Backbone.Collection(this.model.get('MESSAGES')), embed: true
}))
this.wrappedView = new (this.getOption('childView'))({
model: this.model,
templateHelpers: this.getOption('templateHelpers'),
holderWidth: this.getOption('holderWidth'),
})
this.wrapper.show(this.wrappedView)

if (!this.model.get('AUTOMATIC')) {
this.ui.links.html('<i class="fa fa-refresh" title="Reprocessed"></i> ')
}

var mapButton = null
if (this.getOption('links')) {
var links = [
'<a class="view button" href="/dc/map/id/'+this.getOption('DCID')+'/aid/'+this.model.get('AID')+'"><i class="fa fa-search"></i> Map / Model Viewer</a>',
Expand All @@ -88,7 +83,17 @@ define(['backbone', 'marionette',
}

this.ui.links.append(links.join(' '))
mapButton = this.ui.links.find('a.view')
}

this.wrappedView = new (this.getOption('childView'))({
model: this.model,
templateHelpers: this.getOption('templateHelpers'),
holderWidth: this.getOption('holderWidth'),
mapButton: mapButton,
})
this.wrapper.show(this.wrappedView)

},

onDomRefresh: function() {
Expand Down
Loading
Loading