Skip to content

Commit f8ead87

Browse files
ndg63276Mark Williams
andauthored
LIMS-1917: Track status of strategy pipelines (#993)
* LIMS-1917: Track status of strategy pipelines * LIMS-1917: Hide strategy pipelines from downstream results --------- Co-authored-by: Mark Williams <[email protected]>
1 parent 0aa1820 commit f8ead87

File tree

5 files changed

+106
-22
lines changed

5 files changed

+106
-22
lines changed

api/src/Page/DC.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,16 @@ function _dc_strategies($id)
12751275
{
12761276
global $strat_align;
12771277

1278-
$rows = $this->db->pq("SELECT s.programversion, st.rankingresolution as rankres, ssw.wedgenumber, sssw.subwedgenumber, ssw.chi, ssw.kappa, ssw.phi, dc.datacollectionid as dcid, s.comments, dc.transmission as dctrn, dc.wavelength as lam, dc.imagedirectory imd, dc.imageprefix as imp, dc.comments as dcc, dc.blsampleid as sid, sl.spacegroup as sg, sl.unitcell_a as a, sl.unitcell_b as b, sl.unitcell_c as c, sl.unitcell_alpha as al, sl.unitcell_beta as be, sl.unitcell_gamma as ga, CONCAT(CONCAT(IF(sssw.comments, sssw.comments, IF(ssw.comments, ssw.comments, s.shortcomments)), ' Wedge'), IFNULL(ssw.wedgenumber, '')) as com, sssw.axisstart as st, sssw.exposuretime as time, sssw.transmission as tran, sssw.oscillationrange as oscran, sssw.resolution as res, sssw.numberofimages as nimg, det.numberofpixelsx, det.detectorpixelsizehorizontal, sssw.rotationaxis
1278+
$rows = $this->db->pq("SELECT s.programversion, s.comments,
1279+
st.rankingresolution as rankres,
1280+
ssw.wedgenumber, ssw.chi, ssw.kappa, ssw.phi, ssw.comments as sswcomments,
1281+
sssw.subwedgenumber, sssw.axisstart as st, sssw.exposuretime as time, sssw.transmission as tran,
1282+
sssw.oscillationrange as oscran, sssw.resolution as res, sssw.numberofimages as nimg, sssw.rotationaxis,
1283+
dc.datacollectionid as dcid, dc.transmission as dctrn, dc.wavelength as lam, dc.imagedirectory imd,
1284+
dc.imageprefix as imp, dc.comments as dcc, dc.blsampleid as sid,
1285+
sl.spacegroup as sg, sl.unitcell_a as a, sl.unitcell_b as b, sl.unitcell_c as c, sl.unitcell_alpha as al, sl.unitcell_beta as be, sl.unitcell_gamma as ga,
1286+
det.numberofpixelsx, det.detectorpixelsizehorizontal,
1287+
CONCAT(IF(sssw.comments, sssw.comments, IF(ssw.comments, ssw.comments, s.shortcomments)), ' Wedge', IFNULL(ssw.wedgenumber, '')) as com
12791288
FROM screeningstrategy st
12801289
INNER JOIN screeningoutput so on st.screeningoutputid = so.screeningoutputid
12811290
INNER JOIN screening s on so.screeningid = s.screeningid
@@ -1303,6 +1312,11 @@ function _dc_strategies($id)
13031312
}
13041313

13051314
if ($is_align) {
1315+
foreach ($r as $k => &$v) {
1316+
if (in_array($k, $nf)) {
1317+
$v = number_format(floatval($v), 2);
1318+
}
1319+
}
13061320
array_push($output[$r['PROGRAMVERSION']]['STRATS'], $r);
13071321
} else {
13081322

api/src/Page/Processing.php

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,27 @@ function _screening_status($where, $ids) {
148148
INNER JOIN datacollectiongroup dcg on dc.datacollectiongroupid = dcg.datacollectiongroupid
149149
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
150150
INNER JOIN proposal p ON p.proposalid = s.proposalid
151-
WHERE $where
152-
GROUP BY dc.datacollectionid, sc.programversion",
151+
WHERE sc.autoprocprogramid is null AND $where",
153152
$ids
154153
);
155154

156155
$statuses = array();
157-
foreach ($screenings as $screening) {
158-
if (!array_key_exists($screening['DATACOLLECTIONID'], $statuses)) {
159-
$statuses[$screening['DATACOLLECTIONID']][
160-
'screening'
161-
] = array();
156+
foreach ($screenings as $s) {
157+
if (!array_key_exists($s['DATACOLLECTIONID'], $statuses)) {
158+
$statuses[$s['DATACOLLECTIONID']] = array();
162159
}
163-
164-
$statuses[$screening['DATACOLLECTIONID']]['screening'][
165-
$screening['PROGRAMVERSION']
166-
] = $this->_map_status($screening["INDEXINGSUCCESS"]);
160+
if (!array_key_exists('screening', $statuses[$s['DATACOLLECTIONID']])
161+
) {
162+
$statuses[$s['DATACOLLECTIONID']]['screening'] = array();
163+
}
164+
if (!array_key_exists($s['PROGRAMVERSION'], $statuses[$s['DATACOLLECTIONID']]['screening'])
165+
) {
166+
$statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']] = array();
167+
}
168+
array_push(
169+
$statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']],
170+
$this->_map_status($s['INDEXINGSUCCESS'])
171+
);
167172
}
168173

169174
return $statuses;
@@ -204,8 +209,9 @@ function _xrc_status($where, $ids) {
204209
}
205210

206211
function _autoproc_status($where, $ids) {
207-
global $downstream_filter;
212+
global $downstream_filter, $strat_align;
208213
$filter = $downstream_filter ? implode("','", $downstream_filter) : '';
214+
$screening_filter = $strat_align ? implode("','", $strat_align) : '';
209215

210216
$processings = $this->db->union(
211217
array(
@@ -216,7 +222,9 @@ function _autoproc_status($where, $ids) {
216222
INNER JOIN proposal p ON p.proposalid = s.proposalid
217223
INNER JOIN autoprocintegration api ON api.datacollectionid = dc.datacollectionid
218224
INNER JOIN autoprocprogram app ON api.autoprocprogramid = app.autoprocprogramid
219-
WHERE $where AND app.processingprograms NOT IN ('$filter')",
225+
WHERE $where
226+
AND app.processingprograms NOT IN ('$filter')
227+
AND app.processingprograms NOT IN ('$screening_filter')",
220228
"SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'downstream' as type
221229
FROM datacollection dc
222230
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
@@ -225,8 +233,22 @@ function _autoproc_status($where, $ids) {
225233
INNER JOIN processingjob pj ON pj.datacollectionid = dc.datacollectionid
226234
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
227235
LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid
228-
WHERE $where AND api.autoprocintegrationid IS NULL
229-
AND app.processingprograms NOT IN ('$filter')",
236+
WHERE $where
237+
AND api.autoprocintegrationid IS NULL
238+
AND app.processingprograms NOT IN ('$filter')
239+
AND app.processingprograms NOT IN ('$screening_filter')",
240+
"SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'screening' as type
241+
FROM datacollection dc
242+
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
243+
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
244+
INNER JOIN proposal p ON p.proposalid = s.proposalid
245+
INNER JOIN processingjob pj ON pj.datacollectionid = dc.datacollectionid
246+
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
247+
LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid
248+
WHERE $where
249+
AND api.autoprocintegrationid IS NULL
250+
AND app.processingprograms NOT IN ('$filter')
251+
AND app.processingprograms IN ('$screening_filter')",
230252
),
231253
$ids
232254
);
@@ -280,6 +302,30 @@ function _get_ids() {
280302
return array($where, $ids);
281303
}
282304

305+
function merge_deep_arrays($a, $b) {
306+
foreach ($b as $key => $value) {
307+
if (isset($a[$key])) {
308+
if (is_array($a[$key]) && is_array($value)) {
309+
// Determine if arrays are associative or numeric
310+
if (array_keys($a[$key]) === range(0, count($a[$key]) - 1) &&
311+
array_keys($value) === range(0, count($value) - 1)) {
312+
// Both are numeric arrays - merge them
313+
$a[$key] = array_merge($a[$key], $value);
314+
} else {
315+
// At least one is associative - merge recursively
316+
$a[$key] = $this->merge_deep_arrays($a[$key], $value);
317+
}
318+
} else {
319+
// One is not array, overwrite with $b's value
320+
$a[$key] = $value;
321+
}
322+
} else {
323+
$a[$key] = $value;
324+
}
325+
}
326+
return $a;
327+
}
328+
283329
/**
284330
* All screening, auto processing, and downstream statuses
285331
*/
@@ -308,7 +354,8 @@ function _statuses() {
308354
$xrcs = $this->_xrc_status($where, $ids);
309355
$autoprocs = $this->_autoproc_status($where, $ids);
310356

311-
$statuses = array_replace_recursive($screenings, $xrcs, $autoprocs);
357+
$combined = $this->merge_deep_arrays($screenings, $autoprocs);
358+
$statuses = array_replace_recursive($xrcs, $combined);
312359

313360
$out = array();
314361
foreach ($ids as $id) {
@@ -667,8 +714,9 @@ function _ap_message() {
667714
}
668715

669716
function _get_downstreams($dcid = null, $aid = null) {
670-
global $downstream_filter;
717+
global $downstream_filter, $strat_align;
671718
$filter = $downstream_filter ? implode("','", $downstream_filter) : '';
719+
$screening_filter = $strat_align ? implode("','", $strat_align) : '';
672720

673721
$where = '';
674722
$args = array($this->proposalid);
@@ -700,6 +748,7 @@ function _get_downstreams($dcid = null, $aid = null) {
700748
INNER JOIN proposal p ON p.proposalid = s.proposalid
701749
WHERE api.autoprocintegrationid IS NULL AND p.proposalid=:1 $where
702750
AND app.processingprograms NOT IN ('$filter')
751+
AND app.processingprograms NOT IN ('$screening_filter')
703752
GROUP BY app.autoprocprogramid",
704753
$args
705754
);

client/src/js/modules/dc/views/apstatusitem.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ define(['marionette', 'jquery'], function(Marionette, $) {
5252

5353
if (this.getOption('showStrategies')) {
5454
this.ui.strat.empty()
55+
var allStrategies = []
5556
_.each(res['screening'], function(sc, n) {
56-
this.ui.strat.append(n+': '+val[sc]+' ')
57+
var strats = {}
58+
_.each(sc, function(a) {
59+
if (!(a in strats)) strats[a] = 0
60+
strats[a]++
61+
})
62+
allStrategies.push(n+': '+_.map(strats, function(c, st) { return c > 1 ? '<span class="count">'+c+'x</span> '+val[st] : val[st]}).join(' '))
5763
}, this)
64+
this.ui.strat.append(allStrategies.join('<span class="separator">|</span>'))
5865
}
5966

6067
if (this.getOption('showProcessing')) {

client/src/js/modules/dc/views/autoindexing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define(['marionette',
88
modelEvents: { 'change': 'render' },
99

1010
getTemplate: function(m) {
11-
return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE') == 'dials.align_crystal') ? xotemplate : template
11+
return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE').includes('dials.align_crystal')) ? xotemplate : template
1212
}
1313
})
1414

@@ -31,4 +31,4 @@ define(['marionette',
3131

3232
})
3333

34-
})
34+
})

client/src/js/templates/dc/dc_xoalign.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,29 @@ <h2><%-TYPE%></h2>
99
<th>Kappa</th>
1010
<th>Chi</th>
1111
<th>Phi</th>
12+
<th>Space Group</th>
13+
<th>A</th>
14+
<th>B</th>
15+
<th>C</th>
16+
<th>α</th>
17+
<th>β</th>
18+
<th>γ</th>
1219
</tr>
1320
</thead>
1421
<tbody>
1522
<% _.each(STRATS, function(r, i) { %>
1623
<tr class="stratrow">
17-
<td><%-r.COMMENTS %></td>
24+
<td><%-r.SSWCOMMENTS %></td>
1825
<td><%-r.KAPPA %></td>
1926
<td><%-r.CHI %></td>
2027
<td><%-r.PHI %></td>
28+
<td><%-r.SG %></td>
29+
<td><%-r.A %></td>
30+
<td><%-r.B %></td>
31+
<td><%-r.C %></td>
32+
<td><%-r.AL %></td>
33+
<td><%-r.BE %></td>
34+
<td><%-r.GA %></td>
2135
</tr>
2236
<% }) %>
2337
</tbody>

0 commit comments

Comments
 (0)