Skip to content

Commit 3ade510

Browse files
ndg63276Mark Williams
andauthored
Merge pre-release/2025-R5.1 into master (#1002)
* LIMS-1759: Add pages to create and view ligands (#957) * LIMS-1759: Add pages to add/view/list ligands, add PDBS, and add to samples * LIMS-1759: Add ligands to samples in plates * LIMS-1759: Fix bug where ligands were added multiple times * LIMS-1759: Fix error with too few args --------- Co-authored-by: Mark Williams <[email protected]> * LIMS-1926: Hide barcode field when viewing a puck (#991) Co-authored-by: Mark Williams <[email protected]> * LIMS-1963: Load all logins for a proposal (#998) Co-authored-by: Mark Williams <[email protected]> * 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]> --------- Co-authored-by: Mark Williams <[email protected]>
1 parent 5b91a20 commit 3ade510

37 files changed

+1403
-78
lines changed

api/src/Database/Type/MySQL.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class MySQL extends DatabaseParent {
135135
'BLSampleImageAutoScoreClass',
136136
'BLSampleImage_has_AutoScoreClass',
137137

138+
'Ligand',
139+
'BLSample_has_Ligand',
140+
'Ligand_has_PDB',
141+
138142
// Queuing
139143
'ContainerQueueSample',
140144
'ContainerQueue',

api/src/Page/DC.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DC extends Page
1919
'aid' => '\d+',
2020
'pjid' => '\d+',
2121
'pid' => '\d+',
22+
'lid' => '\d+',
2223
'h' => '\d\d',
2324
'dmy' => '\d\d\d\d\d\d\d\d',
2425
'ssid' => '\d+',
@@ -259,6 +260,16 @@ function _data_collections($single = null)
259260
array_push($args, $this->arg('pid'));
260261
}
261262

263+
# Ligands
264+
} else if ($this->has_arg('lid')) {
265+
$info = $this->db->pq("SELECT ligandid FROM ligand l WHERE l.ligandid=:1", array($this->arg('lid')));
266+
267+
foreach (array('dc', 'es', 'r', 'xrf') as $i => $t) {
268+
$extj[$i] .= " INNER JOIN blsample_has_ligand bhl ON bhl.blsampleid = smp.blsampleid";
269+
$sess[$i] = 'bhl.ligandid=:' . (sizeof($args) + 1);
270+
array_push($args, $this->arg('lid'));
271+
}
272+
262273
# Processing job
263274
} else if ($this->has_arg('PROCESSINGJOBID')) {
264275
$info = $this->db->pq('SELECT processingjobid
@@ -1264,7 +1275,16 @@ function _dc_strategies($id)
12641275
{
12651276
global $strat_align;
12661277

1267-
$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
12681288
FROM screeningstrategy st
12691289
INNER JOIN screeningoutput so on st.screeningoutputid = so.screeningoutputid
12701290
INNER JOIN screening s on so.screeningid = s.screeningid
@@ -1292,6 +1312,11 @@ function _dc_strategies($id)
12921312
}
12931313

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

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
);

api/src/Page/Proposal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Proposal extends Page
3737
'SHIPPINGID' => '\d+',
3838
'LABCONTACTID' => '\d+',
3939
'DATACOLLECTIONID' => '\d+',
40+
'LIGANDID' => '\d+',
4041

4142
// proposal
4243
'PROPOSALCODE' => '\w+',
@@ -900,6 +901,7 @@ function _lookup()
900901
'SHIPPINGID' => 'sh.shippingid',
901902
'LABCONTACTID' => 'lc.labcontactid',
902903
'DATACOLLECTIONID' => 'dc.datacollectionid',
904+
'LIGANDID' => 'l.ligandid',
903905
);
904906

905907
$field = null;
@@ -958,6 +960,7 @@ function _lookup()
958960
LEFT OUTER JOIN container c ON c.dewarid = d.dewarid
959961
960962
LEFT OUTER JOIN labcontact lc ON lc.proposalid = p.proposalid
963+
LEFT OUTER JOIN ligand l ON l.proposalid = p.proposalid
961964
$where
962965
", $args);
963966

0 commit comments

Comments
 (0)