Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-1432: Add shelxt downstream view #818

Merged
merged 16 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
91 changes: 91 additions & 0 deletions api/src/Downstream/Type/Shelxt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace SynchWeb\Downstream\Type;

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

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

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

function _get_shelxt_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_pdb() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filepath, app.filename from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.pdb%' ",
$appid
);
if (sizeof($filepath)) {
return $filepath[0]["FILEPATH"] . "/" . $filepath[0]["FILENAME"];
} else {
return;
}
}

function results() {
$json_filepath = $this->_get_shelxt_results_json();
if (sizeof($json_filepath)) {
$json_path = $json_filepath[0]["FILEPATH"] . "/shelxt_results.json" ;
$json_data = file_get_contents($json_path);
} else {
$json_data = "[]";
}
$dat = array();
$dat['BLOBS'] = 1;
$dat['SOLUTIONS'] = json_decode($json_data);

// scaling_id should always be present, but just in case...
if (in_array('scaling_id', $this->process['PARAMETERS'])) {
$integrator = $this->_lookup_autoproc(
null,
$this->process['PARAMETERS']['scaling_id']
);
if ($integrator) {
$dat['PARENTAUTOPROCPROGRAM'] = $integrator['PROCESSINGPROGRAMS'];
$dat['PARENTAUTOPROCPROGRAMID'] = $integrator['AUTOPROCPROGRAMID'];
}
}
$results = new DownstreamResult($this);
$results->data = $dat;

return $results;
}

function images($n = 0) {
$png = $this->_get_shelxt_results_png();
if (sizeof($png)) {
return $png[0]["FILEPATH"] . "/" . $png[0]["FILENAME"];
} else {
return;
}

}

function mapmodel($n = 0, $map = false) {
$pdb = $this->_get_pdb();
if (!$pdb) {
return;
} else {
return $pdb;
}
}
}
4 changes: 3 additions & 1 deletion client/src/js/modules/dc/views/downstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ define(['backbone', 'marionette',
'modules/dc/views/dimple',
'modules/dc/views/mrbump',
'modules/dc/views/bigep',
'modules/dc/views/shelxt',
'templates/dc/downstreamerror.html'

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

var DownstreamsCollection = Backbone.Collection.extend()

Expand Down Expand Up @@ -61,6 +62,7 @@ define(['backbone', 'marionette',
'Autobuild': BigEP,
'Crank2': BigEP,
'AutoSHARP': BigEP,
'Shelxt': Shelxt,
}

if (model.get('PROCESS').PROCESSINGSTATUS != 1) {
Expand Down
44 changes: 44 additions & 0 deletions client/src/js/modules/dc/views/shelxt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
define([
'marionette', 'templates/dc/dc_shelxt.html', 'utils', 'utils/xhrimage', 'jquery.mp'
], function(Marionette, template, utils, XHRImage) {

return Marionette.ItemView.extend({
template: template,
className: 'clearfix',

ui: {
solutions: '.solutions',
blob: '.blobs img',
blobs: '.blobs',
},

showBlob: function() {
this.ui.blob.attr('src', this.blob.src).show()
this.ui.blobs.addClass('loaded').removeClass('pending')
},

onDomRefresh: function() {
this.ui.blobs.magnificPopup({
delegate: 'a', type: 'image',
gallery: {
enabled: true,
navigateByImgClick: true,
}
})

this.ui.blob.hide()
if (this.model.get('BLOBS') > 0) {
this.blob = new XHRImage()
this.blob.onload = this.showBlob.bind(this)
this.ui.blobs.addClass('pending')
this.blob.load(app.apiurl+'/processing/downstream/images/'+this.model.get('AID'))
}

if (!app.mobile()) {
this.ui.solutions.width(0.47*(this.options.holderWidth-14))
}
},

})

})
25 changes: 18 additions & 7 deletions client/src/js/modules/types/sm/dc/views/apstatusitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@ define(['modules/dc/views/apstatusitem'], function(APStatusItem) {
'<i class="fa icon green fa-check alt="Completed"></i>',
'<i class="fa icon red fa-times alt="Failed"></i>']

_.each(['autoproc','downstream'], function(ty, id) {
this.ui.holder.eq(id).empty()
_.each(res[ty], function(ap, n) {
if(ap != 0)
this.ui.holder.eq(id).append(n+' '+val[ap]+' ')
}, this)
_.each({ap: 'autoproc',dp: 'downstream'}, function(ty, id) {
this.ui[id].empty()
var allResults = []
if (res[ty]) {
_.each(res[ty], function(ap, n) {
var ress = {}
_.each(ap, function(a) {
if (!(a in ress)) ress[a] = 0
ress[a]++
})
allResults.push(n+': '+_.map(ress, function(c, st) { return c > 1 ? '<span class="count">'+c+'x</span> '+val[st] : val[st]}).join(' '))
}, this)

this.ui[id].append(allResults.join('<span class="separator">|</span>'))
} else {
this.ui[id].append('No processing results')
}
}, this)
},
})

})
})
32 changes: 32 additions & 0 deletions client/src/js/templates/dc/dc_shelxt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div>
<div class="blobs">
<% _.each(_.range(BLOBS), function(i) { %>
<a href="<%-APIURL%>/processing/downstream/images/<%-AID%>?n=<%-i%>" title="Solution <%-i+1%>">
<% if (i == 0) { %>
<img alt="Solution 1" />
<% } %>
</a>
<% }) %>

</div>

<table class="rstats">
<% if (SOLUTIONS.length) { %>
<% _.each(SOLUTIONS, function(r, i) { %>
<tr>
<% _.each(r, function(j) { %>
<td><%-j%></td>
<% }) %>
</tr>
<% }) %>
<% } else { %>
<tr>
<td>Solutions</td>
</tr>
<tr>
<td>No Solutions Found</td>
</tr>
<% } %>
</table>

</div>
Loading