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
16 changes: 15 additions & 1 deletion api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,16 @@ function _dc_strategies($id)
{
global $strat_align;

$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
$rows = $this->db->pq("SELECT s.programversion, s.comments,
st.rankingresolution as rankres,
ssw.wedgenumber, ssw.chi, ssw.kappa, ssw.phi, ssw.comments as sswcomments,
sssw.subwedgenumber, sssw.axisstart as st, sssw.exposuretime as time, sssw.transmission as tran,
sssw.oscillationrange as oscran, sssw.resolution as res, sssw.numberofimages as nimg, sssw.rotationaxis,
dc.datacollectionid as dcid, 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,
det.numberofpixelsx, det.detectorpixelsizehorizontal,
CONCAT(IF(sssw.comments, sssw.comments, IF(ssw.comments, ssw.comments, s.shortcomments)), ' Wedge', IFNULL(ssw.wedgenumber, '')) as com
FROM screeningstrategy st
INNER JOIN screeningoutput so on st.screeningoutputid = so.screeningoutputid
INNER JOIN screening s on so.screeningid = s.screeningid
Expand Down Expand Up @@ -1292,6 +1301,11 @@ function _dc_strategies($id)
}

if ($is_align) {
foreach ($r as $k => &$v) {
if (in_array($k, $nf)) {
$v = number_format(floatval($v), 2);
}
}
array_push($output[$r['PROGRAMVERSION']]['STRATS'], $r);
} else {

Expand Down
83 changes: 66 additions & 17 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,27 @@ function _screening_status($where, $ids) {
INNER JOIN datacollectiongroup dcg on dc.datacollectiongroupid = dcg.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE $where
GROUP BY dc.datacollectionid, sc.programversion",
WHERE sc.autoprocprogramid is null AND $where",
$ids
);

$statuses = array();
foreach ($screenings as $screening) {
if (!array_key_exists($screening['DATACOLLECTIONID'], $statuses)) {
$statuses[$screening['DATACOLLECTIONID']][
'screening'
] = array();
foreach ($screenings as $s) {
if (!array_key_exists($s['DATACOLLECTIONID'], $statuses)) {
$statuses[$s['DATACOLLECTIONID']] = array();
}

$statuses[$screening['DATACOLLECTIONID']]['screening'][
$screening['PROGRAMVERSION']
] = $this->_map_status($screening["INDEXINGSUCCESS"]);
if (!array_key_exists('screening', $statuses[$s['DATACOLLECTIONID']])
) {
$statuses[$s['DATACOLLECTIONID']]['screening'] = array();
}
if (!array_key_exists($s['PROGRAMVERSION'], $statuses[$s['DATACOLLECTIONID']]['screening'])
) {
$statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']] = array();
}
array_push(
$statuses[$s['DATACOLLECTIONID']]['screening'][$s['PROGRAMVERSION']],
$this->_map_status($s['INDEXINGSUCCESS'])
);
}

return $statuses;
Expand Down Expand Up @@ -204,8 +209,9 @@ function _xrc_status($where, $ids) {
}

function _autoproc_status($where, $ids) {
global $downstream_filter;
global $downstream_filter, $strat_align;
$filter = $downstream_filter ? implode("','", $downstream_filter) : '';
$screening_filter = $strat_align ? implode("','", $strat_align) : '';

$processings = $this->db->union(
array(
Expand All @@ -216,7 +222,9 @@ function _autoproc_status($where, $ids) {
INNER JOIN proposal p ON p.proposalid = s.proposalid
INNER JOIN autoprocintegration api ON api.datacollectionid = dc.datacollectionid
INNER JOIN autoprocprogram app ON api.autoprocprogramid = app.autoprocprogramid
WHERE $where AND app.processingprograms NOT IN ('$filter')",
WHERE $where
AND app.processingprograms NOT IN ('$filter')
AND app.processingprograms NOT IN ('$screening_filter')",
"SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'downstream' as type
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
Expand All @@ -225,8 +233,22 @@ function _autoproc_status($where, $ids) {
INNER JOIN processingjob pj ON pj.datacollectionid = dc.datacollectionid
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid
WHERE $where AND api.autoprocintegrationid IS NULL
AND app.processingprograms NOT IN ('$filter')",
WHERE $where
AND api.autoprocintegrationid IS NULL
AND app.processingprograms NOT IN ('$filter')
AND app.processingprograms NOT IN ('$screening_filter')",
"SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'screening' as type
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 pj ON pj.datacollectionid = dc.datacollectionid
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid
WHERE $where
AND api.autoprocintegrationid IS NULL
AND app.processingprograms NOT IN ('$filter')
AND app.processingprograms IN ('$screening_filter')",
),
$ids
);
Expand Down Expand Up @@ -280,6 +302,30 @@ function _get_ids() {
return array($where, $ids);
}

function merge_deep_arrays($a, $b) {
foreach ($b as $key => $value) {
if (isset($a[$key])) {
if (is_array($a[$key]) && is_array($value)) {
// Determine if arrays are associative or numeric
if (array_keys($a[$key]) === range(0, count($a[$key]) - 1) &&
array_keys($value) === range(0, count($value) - 1)) {
// Both are numeric arrays - merge them
$a[$key] = array_merge($a[$key], $value);
} else {
// At least one is associative - merge recursively
$a[$key] = $this->merge_deep_arrays($a[$key], $value);
}
} else {
// One is not array, overwrite with $b's value
$a[$key] = $value;
}
} else {
$a[$key] = $value;
}
}
return $a;
}

/**
* All screening, auto processing, and downstream statuses
*/
Expand Down Expand Up @@ -308,7 +354,8 @@ function _statuses() {
$xrcs = $this->_xrc_status($where, $ids);
$autoprocs = $this->_autoproc_status($where, $ids);

$statuses = array_replace_recursive($screenings, $xrcs, $autoprocs);
$combined = $this->merge_deep_arrays($screenings, $autoprocs);
$statuses = array_replace_recursive($xrcs, $combined);

$out = array();
foreach ($ids as $id) {
Expand Down Expand Up @@ -667,8 +714,9 @@ function _ap_message() {
}

function _get_downstreams($dcid = null, $aid = null) {
global $downstream_filter;
global $downstream_filter, $strat_align;
$filter = $downstream_filter ? implode("','", $downstream_filter) : '';
$screening_filter = $strat_align ? implode("','", $strat_align) : '';

$where = '';
$args = array($this->proposalid);
Expand Down Expand Up @@ -700,6 +748,7 @@ function _get_downstreams($dcid = null, $aid = null) {
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE api.autoprocintegrationid IS NULL AND p.proposalid=:1 $where
AND app.processingprograms NOT IN ('$filter')
AND app.processingprograms NOT IN ('$screening_filter')
GROUP BY app.autoprocprogramid",
$args
);
Expand Down
9 changes: 8 additions & 1 deletion client/src/js/modules/dc/views/apstatusitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ define(['marionette', 'jquery'], function(Marionette, $) {

if (this.getOption('showStrategies')) {
this.ui.strat.empty()
var allStrategies = []
_.each(res['screening'], function(sc, n) {
this.ui.strat.append(n+': '+val[sc]+' ')
var strats = {}
_.each(sc, function(a) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could maybe use native JS here, but it doesn't bother me too much

if (!(a in strats)) strats[a] = 0
strats[a]++
})
allStrategies.push(n+': '+_.map(strats, function(c, st) { return c > 1 ? '<span class="count">'+c+'x</span> '+val[st] : val[st]}).join(' '))
}, this)
this.ui.strat.append(allStrategies.join('<span class="separator">|</span>'))
}

if (this.getOption('showProcessing')) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/modules/dc/views/autoindexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(['marionette',
modelEvents: { 'change': 'render' },

getTemplate: function(m) {
return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE') == 'dials.align_crystal') ? xotemplate : template
return (this.model.get('TYPE') == 'XOalign' || this.model.get('TYPE').includes('dials.align_crystal')) ? xotemplate : template
}
})

Expand All @@ -31,4 +31,4 @@ define(['marionette',

})

})
})
16 changes: 15 additions & 1 deletion client/src/js/templates/dc/dc_xoalign.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@ <h2><%-TYPE%></h2>
<th>Kappa</th>
<th>Chi</th>
<th>Phi</th>
<th>Space Group</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>α</th>
<th>β</th>
<th>γ</th>
</tr>
</thead>
<tbody>
<% _.each(STRATS, function(r, i) { %>
<tr class="stratrow">
<td><%-r.COMMENTS %></td>
<td><%-r.SSWCOMMENTS %></td>
<td><%-r.KAPPA %></td>
<td><%-r.CHI %></td>
<td><%-r.PHI %></td>
<td><%-r.SG %></td>
<td><%-r.A %></td>
<td><%-r.B %></td>
<td><%-r.C %></td>
<td><%-r.AL %></td>
<td><%-r.BE %></td>
<td><%-r.GA %></td>
</tr>
<% }) %>
</tbody>
Expand Down
Loading