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
2 changes: 1 addition & 1 deletion api/src/Downstream/Type/Dimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function results() {
return;
}

$lfs = $this->_get_attachments(null, null, 'refmac5_restr.log');
$lfs = $this->_get_attachments(null, null, 'refmac%_restr.log');
if (sizeof($lfs)) {
$lf = $lfs[0]['FILE'];
} else {
Expand Down
3 changes: 2 additions & 1 deletion api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ function _dc_strategies($id)
global $strat_align;

$rows = $this->db->pq("SELECT s.programversion, s.comments,
st.rankingresolution as rankres,
st.rankingresolution as rankres, sssw.dosetotal, st.screeningstrategyid,
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,
Expand Down Expand Up @@ -1199,6 +1199,7 @@ function _dc_strategies($id)
$output[$t] = array('CELL' => array(), 'STRATS' => array());

$r['ATRAN'] = $r['TRAN'] / 100.0 * $r['DCTRN'];
$r['ROTATION'] = $r['NIMG'] * $r['OSCRAN'];
foreach ($nf as $nff => $cols) {
foreach ($cols as $c) {
$r[$c] = number_format($r[$c], $nff);
Expand Down
77 changes: 61 additions & 16 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Processing extends Page {
public static $dispatch = array(
array('/:id(/dcg/:dcg)', 'get', '_results'),
array('/visit/:visit(/csv/:csv)', 'get', '_results_for_visit'),
array('/summary(/group/:sgid)(/protein/:pid)(/visit/:visit)(/csv/:csv)', 'get', '_summary'),
array('/status', 'post', '_statuses'),

array('/messages/status', 'post', '_ap_message_status'),
Expand All @@ -27,6 +27,8 @@ class Processing extends Page {
'id' => '\d+',
'ids' => '\d+',
'dcg' => '\d+',
'pid' => '\d+',
'sgid' => '\d+',
'visit' => '\w+\d+-\d+',
'map' => '\d+',
'n' => '\d+',
Expand Down Expand Up @@ -382,24 +384,56 @@ function _statuses() {
$this->_output($out);
}

function _results_for_visit() {
if (!($this->has_arg('visit'))) {
$this->_error('No visit specified');
}
$pattern = '/([A-z]+)(\d+)-(\d+)/';
preg_match($pattern, $this->arg('visit'), $matches);
if (!sizeof($matches))
$this->_error('No such visit');
function _summary() {
$where = 'dc.overlap = 0 AND dc.axisrange > 0 AND app.processingstatus = 1';
$join = '';
if ($this->has_arg('visit')) {
$pattern = '/([A-z]+)(\d+)-(\d+)/';
preg_match($pattern, $this->arg('visit'), $matches);
if (!sizeof($matches))
$this->_error('No such visit');

$info = $this->db->pq("SELECT s.sessionid FROM blsession s
INNER JOIN proposal p ON (p.proposalid = s.proposalid)
WHERE p.proposalid=:1 AND p.proposalcode=:2 AND p.proposalnumber=:3 AND s.visit_number=:4",
array($this->proposalid, $matches[1], $matches[2], $matches[3])
);

$info = $this->db->pq("SELECT s.sessionid FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode=:1 AND p.proposalnumber=:2 AND s.visit_number=:3", array($matches[1], $matches[2], $matches[3]));
if (!sizeof($info)) {
$this->_error('No such visit');
}

if (!sizeof($info)) {
$this->_error('No such visit');
}
$args = array($info[0]['SESSIONID']);
$where .= ' AND dc.sessionid=:1';
} else if ($this->has_arg('pid')) {
$info = $this->db->pq("SELECT pr.proteinid FROM protein pr
WHERE pr.proposalid=:1 AND pr.proteinid=:2",
array($this->proposalid, $this->arg('pid'))
);

if (!sizeof($info)) {
$this->_error('No such protein');
}

$args = array($info[0]['PROTEINID']);
$where .= ' AND c.proteinid=:1';
$join = 'INNER JOIN crystal c on smp.crystalid=c.crystalid';
} else if ($this->has_arg('sgid')) {
$info = $this->db->pq("SELECT blsg.blsamplegroupid FROM blsamplegroup blsg
WHERE blsg.proposalid=:1 AND blsg.blsamplegroupid=:2",
array($this->proposalid, $this->arg('sgid'))
);

$args = array($info[0]['SESSIONID']);
if (!sizeof($info)) {
$this->_error('No such sample group');
}

$where = 'dc.sessionid=:1 AND dc.overlap = 0 AND dc.axisrange > 0 AND app.processingstatus = 1';
$args = array($info[0]['BLSAMPLEGROUPID']);
$where .= ' AND bhb.blsamplegroupid=:1';
$join = 'INNER JOIN BLSampleGroup_has_BLSample bhb on smp.blsampleid=bhb.blsampleid';
} else {
$this->_error('No visit, protein or group specified');
}

if ($this->has_arg('pipeline')) {
$st = sizeof($args);
Expand Down Expand Up @@ -489,6 +523,7 @@ function _results_for_visit() {
$jobs = $this->db->pq(
"SELECT dc.datacollectionid as id,
CONCAT(dc.imageprefix, '_', dc.datacollectionnumber) as prefix,
CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit,
smp.name as sample,
smp.blsampleid,
".self::EVTOA."/dc.wavelength as energy,
Expand Down Expand Up @@ -518,7 +553,10 @@ function _results_for_visit() {
apssinner.ccanomalous as innerccanom,
app.autoprocprogramid as aid
FROM datacollection dc
INNER JOIN blsession s ON dc.sessionid = s.sessionid
INNER JOIN proposal p ON s.proposalid = p.proposalid
LEFT OUTER JOIN blsample smp ON dc.blsampleid = smp.blsampleid
$join
INNER JOIN processingjob pj ON dc.datacollectionid = pj.datacollectionid
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
INNER JOIN autoproc ap ON app.autoprocprogramid=ap.autoprocprogramid
Expand Down Expand Up @@ -583,7 +621,14 @@ function _results_for_visit() {

if ($this->has_arg('csv')) {
$this->app->response->headers->set("Content-type", "text/csv");
Utils::setDispositionAttachment($this->app->response, $this->arg('visit') . "_summary.csv");
if ($this->has_arg('visit')) {
$filename = 'visit_' . $this->arg('visit') . "_summary.csv";
} else if ($this->has_arg('pid')) {
$filename = 'protein_' . $this->arg('pid') . "_summary.csv";
} else {
$filename = 'group_' . $this->arg('sgid') . "_summary.csv";
}
Utils::setDispositionAttachment($this->app->response, $filename);
if (!empty($data)) {
print implode(',', array_keys($data[0])) . "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ function _distinct_proteins()
LEFT OUTER JOIN concentrationtype ct ON ct.concentrationtypeid = pr.concentrationtypeid
WHERE pr.acronym is not null AND $where
GROUP BY ct.symbol, pr.acronym, pr.name, pr.global
ORDER BY lower(pr.acronym)", $args);
ORDER BY lower(pr.acronym), pr.proteinid", $args);

$this->_output($rows);
}
Expand Down
Loading
Loading