Skip to content

Commit

Permalink
Merge 2024-R3.3 into master (#813)
Browse files Browse the repository at this point in the history
* LIMS-1370: Handle errors from the shipping service (#804)

* LIMS-1330: Use experimentTypeId if specified (#796)

* LIMS-1240: Dont use shortComments LIKE 'EDNA%' (#795)

* LIMS-1350: Display crystal snapshots even if zipped (#807)

* LIMS-1369: Make fault report titles editable (#802)

* LIMS-1341: Allow entry of SMILES codes (#793)
  • Loading branch information
ndg63276 authored Aug 12, 2024
1 parent ed7962d commit c044628
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 33 deletions.
1 change: 1 addition & 0 deletions api/src/Database/Type/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class MySQL extends DatabaseParent {
'BLSubSample',
'PDB',
'Protein_has_PDB',
'ExperimentType',

// Stat Views
'v_logonByHour',
Expand Down
21 changes: 12 additions & 9 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ function _data_collections($single = null)

$where = '';
if ($this->arg('t') == 'sc')
$where = ' AND (dc.overlap != 0 OR dcg.experimentType = "Screening")';
$where = ' AND (dc.overlap != 0 OR ifnull(et.name, dcg.experimenttype) = "Screening")';
else if ($this->arg('t') == 'gr')
$where = ' AND dc.axisrange = 0';
else if ($this->arg('t') == 'fc')
$where = ' AND dc.overlap = 0 AND dc.axisrange > 0 AND dc.numberOfImages > 1 AND dcg.experimentType != "Screening"';
$where = ' AND dc.overlap = 0 AND dc.axisrange > 0 AND dc.numberOfImages > 1 AND ifnull(et.name, dcg.experimenttype) != "Screening"';
} else if ($this->arg('t') == 'edge') {
$where2 = '';
} else if ($this->arg('t') == 'mca') {
Expand Down Expand Up @@ -156,7 +156,7 @@ function _data_collections($single = null)
// Single crystal or explicitly non-single-crystal fields
$where = ($this->arg('t') == "nscrystal") ? ' AND NOT ' : ' AND ';
// This IS NOT NULL is not redundant; this condition always evalutes to TRUE with AND NOT without it
$where .= '(dcg.experimentType IS NOT NULL AND dcg.experimentType in ("OSC", "Diamond Anvil High Pressure"))';
$where .= '(ifnull(et.name, dcg.experimenttype) IS NOT NULL AND ifnull(et.name, dcg.experimenttype) in ("OSC", "Diamond Anvil High Pressure"))';
}
}

Expand Down Expand Up @@ -396,7 +396,7 @@ function _data_collections($single = null)
dc.kappastart as kappa,
dc.phistart as phi,
dc.startimagenumber as si,
dcg.experimenttype as dct,
ifnull(et.name, dcg.experimenttype) as dct,
dc.datacollectiongroupid as dcg,
dc.runstatus,
dc.beamsizeatsamplex as bsx,
Expand Down Expand Up @@ -476,7 +476,7 @@ function _data_collections($single = null)
dc.kappastart,
dc.phistart,
dc.startimagenumber,
dc.experimenttype,
ifnull(et.name, dcg.experimenttype),
dc.datacollectiongroupid,
dc.runstatus,
dc.beamsizeatsamplex,
Expand Down Expand Up @@ -530,7 +530,7 @@ function _data_collections($single = null)
min(dc.kappastart) as kappa,
min(dc.phistart) as phi,
min(dc.startimagenumber) as si,
min(dcg.experimenttype) as dct,
min(ifnull(et.name, dcg.experimenttype)) as dct,
dc.datacollectiongroupid as dcg,
min(dc.runstatus) as runstatus,
min(dc.beamsizeatsamplex) as bsx,
Expand Down Expand Up @@ -614,6 +614,7 @@ function _data_collections($single = null)
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
$sample_joins[0]
$extj[0]
WHERE $sess[0] $where
Expand Down Expand Up @@ -660,6 +661,7 @@ function _data_collections($single = null)
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
$sample_joins[0]
LEFT OUTER JOIN datacollectioncomment dcc ON dc.datacollectionid = dcc.datacollectionid
LEFT OUTER JOIN datacollectionfileattachment dca ON dc.datacollectionid = dca.datacollectionid
Expand Down Expand Up @@ -963,7 +965,7 @@ function _data_collections($single = null)
$dc['VIS'] = $this->arg('prop') . '-' . $dc['VN'];

foreach (array('X1', 'X2', 'X3', 'X4') as $x) {
$dc[$x] = file_exists($dc[$x]) ? 1 : 0;
$dc[$x] = file_exists($dc[$x]) || file_exists($dc[$x].'.gz') ? 1 : 0;
}

// Data collections
Expand Down Expand Up @@ -1081,8 +1083,9 @@ function _chk_image()
$sn = 0;
$images = array();
foreach (array('X1', 'X2', 'X3', 'X4') as $j => $im) {
array_push($images, file_exists($dc[$im]) ? 1 : 0);
if ($im == 'X1' && file_exists($dc[$im]))
$exists = file_exists($dc[$im]) || file_exists($dc[$im].'.gz');
array_push($images, $exists ? 1 : 0);
if ($im == 'X1' && $exists)
$sn = 1;
unset($dc[$im]);
}
Expand Down
5 changes: 4 additions & 1 deletion api/src/Page/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ function _xtal_image() {
$this->_browser_cache();
$this->app->contentType('image/'.$ext);
readfile($images[$n]);

} else if (file_exists($images[$n].'.gz')) {
$this->_browser_cache();
$this->app->contentType('image/'.$ext);
readgzfile($images[$n].'.gz');
} else {
$this->_error('Not found', 'That image is no longer available');
}
Expand Down
19 changes: 10 additions & 9 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Sample extends Page
'COMPONENTIDS' => '\d+',
'COMPONENTAMOUNTS' => '\d+(.\d+)?',
'ABUNDANCE' => '\d+(.\d+)?',
'SMILES' => '[A-Za-z0-9.:%=#$@+\-\[\]\(\)\/\\\\]+',
'PACKINGFRACTION' => '\d+(.\d+)?',
'DIMENSION1' => '\d+(.\d+)?',
'DIMENSION2' => '\d+(.\d+)?',
Expand Down Expand Up @@ -784,9 +785,6 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc,
count(distinct so.screeningid) as ai,
count(distinct app.autoprocprogramid) as ap,
count(distinct IF(dcg.experimenttype LIKE 'XRF map', dc.datacollectionid, NULL)) as xm,
count(distinct IF(dcg.experimenttype LIKE 'XRF spectrum', dc.datacollectionid, NULL)) as xs,
count(distinct IF(dcg.experimenttype LIKE 'Energy scan', dc.datacollectionid, NULL)) as es,
round(min(st.rankingresolution),2) as scresolution,
max(ssw.completeness) as sccompleteness,
round(min(apss.resolutionlimithigh),2) as dcresolution,
Expand Down Expand Up @@ -819,7 +817,7 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
LEFT OUTER JOIN screening sc ON dc.datacollectionid = sc.datacollectionid
LEFT OUTER JOIN screeningoutput so ON sc.screeningid = so.screeningid
LEFT OUTER JOIN screeningstrategy st ON st.screeningoutputid = so.screeningoutputid AND sc.shortcomments LIKE '%EDNA%'
LEFT OUTER JOIN screeningstrategy st ON st.screeningoutputid = so.screeningoutputid AND sc.programversion = 'EDNA MXv1'
LEFT OUTER JOIN screeningstrategywedge ssw ON ssw.screeningstrategyid = st.screeningstrategyid
LEFT OUTER JOIN autoprocintegration ap ON ap.datacollectionid = dc.datacollectionid
Expand Down Expand Up @@ -1181,10 +1179,13 @@ function _samples()
$order = $cols[$this->arg('sort_by')] . ' ' . $dir;
}

$rows = $this->db->paginate("SELECT distinct b.blsampleid, b.crystalid, b.screencomponentgroupid, ssp.blsampleid as parentsampleid, ssp.name as parentsample, b.blsubsampleid, count(distinct si.blsampleimageid) as inspections, CONCAT(p.proposalcode,p.proposalnumber) as prop, b.code, b.location, pr.acronym, pr.proteinid, cr.spacegroup,b.comments,b.name,s.shippingname as shipment,s.shippingid,d.dewarid,d.code as dewar, c.code as container, c.containerid, c.samplechangerlocation as sclocation, count(distinct IF(dc.overlap != 0,dc.datacollectionid,NULL)) as sc, count(distinct IF(dc.overlap = 0 AND dc.axisrange = 0,dc.datacollectionid,NULL)) as gr, count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc, count(distinct IF(dcg.experimenttype LIKE 'XRF map', dc.datacollectionid, NULL)) as xm, count(distinct IF(dcg.experimenttype LIKE 'XRF spectrum', dc.datacollectionid, NULL)) as xs, count(distinct IF(dcg.experimenttype LIKE 'Energy scan', dc.datacollectionid, NULL)) as es, count(distinct so.screeningid) as ai, count(distinct app.autoprocprogramid) as ap, count(distinct r.robotactionid) as r, round(min(st.rankingresolution),2) as scresolution, max(ssw.completeness) as sccompleteness, round(min(apss.resolutionlimithigh),2) as dcresolution, round(max(apss.completeness),1) as dccompleteness, dp.anomalousscatterer, dp.requiredresolution, cr.cell_a, cr.cell_b, cr.cell_c, cr.cell_alpha, cr.cell_beta, cr.cell_gamma, b.packingfraction, b.dimension1, b.dimension2, b.dimension3, b.shape, cr.color, cr.theoreticaldensity, cr.name as crystal, pr.name as protein, b.looptype, dp.centringmethod, dp.experimentkind, cq.containerqueueid, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp
$rows = $this->db->paginate("SELECT distinct b.blsampleid, b.crystalid, b.screencomponentgroupid, ssp.blsampleid as parentsampleid, ssp.name as parentsample, b.blsubsampleid, count(distinct si.blsampleimageid) as inspections, CONCAT(p.proposalcode,p.proposalnumber) as prop, b.code, b.location, pr.acronym, pr.proteinid, cr.spacegroup,b.comments,b.name,s.shippingname as shipment,s.shippingid,d.dewarid,d.code as dewar, c.code as container, c.containerid, c.samplechangerlocation as sclocation
, count(distinct IF(dc.overlap != 0,dc.datacollectionid,NULL)) as sc, count(distinct IF(dc.overlap = 0 AND dc.axisrange = 0,dc.datacollectionid,NULL)) as gr, count(distinct IF(dc.overlap = 0 AND dc.axisrange > 0,dc.datacollectionid,NULL)) as dc, count(distinct so.screeningid) as ai, count(distinct app.autoprocprogramid) as ap, count(distinct r.robotactionid) as r, round(min(st.rankingresolution),2) as scresolution, max(ssw.completeness) as sccompleteness
, round(min(apss.resolutionlimithigh),2) as dcresolution, round(max(apss.completeness),1) as dccompleteness, dp.anomalousscatterer, dp.requiredresolution, cr.cell_a, cr.cell_b, cr.cell_c, cr.cell_alpha, cr.cell_beta, cr.cell_gamma, b.packingfraction, b.dimension1, b.dimension2, b.dimension3, b.shape, cr.color, cr.theoreticaldensity, cr.name as crystal, pr.name as protein, b.looptype, dp.centringmethod, dp.experimentkind, cq.containerqueueid
, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp, b.smiles
, $cseq $sseq string_agg(cpr.name) as componentnames, string_agg(cpr.density) as componentdensities
,string_agg(cpr.proteinid) as componentids, string_agg(cpr.acronym) as componentacronyms, string_agg(cpr.global) as componentglobals, string_agg(chc.abundance) as componentamounts, string_agg(ct.symbol) as componenttypesymbols, b.volume, pct.symbol,ROUND(cr.abundance,3) as abundance, TO_CHAR(b.recordtimestamp, 'DD-MM-YYYY') as recordtimestamp, dp.radiationsensitivity, dp.energy, dp.userpath, dp.strategyoption, dp.minimalresolution as minimumresolution
,count(distinct dc.dataCollectionId) as dcc
, string_agg(cpr.proteinid) as componentids, string_agg(cpr.acronym) as componentacronyms, string_agg(cpr.global) as componentglobals, string_agg(chc.abundance) as componentamounts, string_agg(ct.symbol) as componenttypesymbols, b.volume, pct.symbol,ROUND(cr.abundance,3) as abundance, TO_CHAR(b.recordtimestamp, 'DD-MM-YYYY') as recordtimestamp, dp.radiationsensitivity, dp.energy, dp.userpath, dp.strategyoption, dp.minimalresolution as minimumresolution
, count(distinct dc.dataCollectionId) as dcc
FROM blsample b
Expand All @@ -1209,7 +1210,7 @@ function _samples()
LEFT OUTER JOIN screening sc ON dc.datacollectionid = sc.datacollectionid
LEFT OUTER JOIN screeningoutput so ON sc.screeningid = so.screeningid
LEFT OUTER JOIN screeningstrategy st ON st.screeningoutputid = so.screeningoutputid AND sc.shortcomments LIKE '%EDNA%'
LEFT OUTER JOIN screeningstrategy st ON st.screeningoutputid = so.screeningoutputid AND sc.programVersion = 'EDNA MXv1'
LEFT OUTER JOIN screeningstrategywedge ssw ON ssw.screeningstrategyid = st.screeningstrategyid
LEFT OUTER JOIN autoprocintegration ap ON ap.datacollectionid = dc.datacollectionid
Expand Down Expand Up @@ -1892,7 +1893,7 @@ function _update_sample()
$this->args['LOCATION'] = $defaultContainerLocation['LOCATION'];
}

$sfields = array('CODE', 'NAME', 'COMMENTS', 'VOLUME', 'PACKINGFRACTION', 'DIMENSION1', 'DIMENSION2', 'DIMENSION3', 'SHAPE', 'POSITION', 'CONTAINERID', 'LOOPTYPE', 'LOCATION');
$sfields = array('CODE', 'NAME', 'COMMENTS', 'VOLUME', 'PACKINGFRACTION', 'DIMENSION1', 'DIMENSION2', 'DIMENSION3', 'SHAPE', 'POSITION', 'CONTAINERID', 'LOOPTYPE', 'LOCATION', 'SMILES');
foreach ($sfields as $f) {
if ($this->has_arg($f)) {
$this->db->pq("UPDATE blsample SET $f=:1 WHERE blsampleid=:2", array($this->arg($f), $samp['BLSAMPLEID']));
Expand Down
13 changes: 8 additions & 5 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ function _dispatch_dewar_in_shipping_service($dispatch_info, $dewar)
$shipment_id = $response['shipmentId'];
$this->shipping_service->dispatch_shipment($shipment_id, false);
} catch (Exception $e) {
throw new Exception("Error returned from shipping service: " . $e . "\nShipment data: " . json_encode($shipment_data));
throw new Exception($e->getMessage());
}

return $shipment_id;
Expand Down Expand Up @@ -1234,12 +1234,15 @@ function _dispatch_dewar()
} else {
try {
$shipment_id = $this->_dispatch_dewar_in_shipping_service($data, $dew);
if (Utils::getValueOrDefault($shipping_service_links_in_emails)) {
$data['AWBURL'] = $this->shipping_service->get_awb_pdf_url($shipment_id);
}
} catch (Exception $e) {
error_log($e);
$data['AWBURL'] = "";
}
if (Utils::getValueOrDefault($shipping_service_links_in_emails)) {
$data['AWBURL'] = $this->shipping_service->get_awb_pdf_url($shipment_id);
$error_json = json_decode($e->getMessage());
$error_response = $error_json->content->detail ?? $e->getMessage();
$error_status = $error_json->status ? $error_json->status : 400;
$this->_error($error_response, $error_status);
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions api/src/Page/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ function _pipelines() {

$t = $this->has_arg('t') ? $this->arg('t') : 'ai';

if (array_key_exists($t, $types)) $this->$types[$t]();
else $this->_error('No such stat type');
if (array_key_exists($t, $types)) {
$func = $types[$t];
$this->$func();
} else {
$this->_error('No such stat type');
}
}


Expand All @@ -275,7 +279,7 @@ function _auto_indexing() {
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
INNER JOIN v_run vr ON (ses.startdate BETWEEN vr.startdate AND vr.enddate)
WHERE s.shortcomments LIKE 'EDNA%' AND TIMESTAMPDIFF('SECOND', dc.endtime, s.bltimestamp) < 10000
WHERE s.shortcomments LIKE 'Strategy%' AND TIMESTAMPDIFF('SECOND', dc.endtime, s.bltimestamp) between 0 and 10000
AND ses.beamlinename in ('$bls')
GROUP BY s.shortcomments, vr.run
ORDER BY vr.run
Expand Down
8 changes: 5 additions & 3 deletions api/src/Page/Vstat.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,22 @@ function _error_log()
{
$info = $this->_check_visit();

$dc_tot = $this->db->pq("SELECT dcg.experimenttype, count(dc.datacollectionid) as total
$dc_tot = $this->db->pq("SELECT ifnull(et.name, dcg.experimenttype) as experimenttype, count(dc.datacollectionid) as total
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dc.datacollectiongroupid = dcg.datacollectiongroupid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
WHERE dcg.sessionid=:1
GROUP BY dcg.experimenttype", array($info['SID']));
GROUP BY ifnull(et.name, dcg.experimenttype)", array($info['SID']));

$totals = array();
foreach ($dc_tot as $tot) {
$totals[$tot['EXPERIMENTTYPE']] = intval($tot["TOTAL"]);
}

$dcs = $this->db->pq("SELECT dc.datacollectionid, dcg.experimenttype, dc.starttime, dc.endtime, dc.filetemplate, dc.imagedirectory, dc.runstatus, dca.filefullpath as logfile
$dcs = $this->db->pq("SELECT dc.datacollectionid, ifnull(et.name, dcg.experimenttype) as experimenttype, dc.starttime, dc.endtime, dc.filetemplate, dc.imagedirectory, dc.runstatus, dca.filefullpath as logfile
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dc.datacollectiongroupid = dcg.datacollectiongroupid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
LEFT OUTER JOIN blsample sam ON dc.blsampleid = sam.blsampleid
LEFT OUTER JOIN datacollectionfileattachment dca ON dca.datacollectionid = dc.datacollectionid AND dca.filetype = 'log'
WHERE dcg.sessionid=:1 AND dc.runstatus NOT LIKE '%success%'", array($info['SID']));
Expand Down
2 changes: 1 addition & 1 deletion api/src/Shipment/ShippingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function _send_request($url, $type, $data, $expected_status_code)
array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => $base_headers,
CURLOPT_TIMEOUT => 5
CURLOPT_TIMEOUT => 10
)
);
switch ($type) {
Expand Down
5 changes: 5 additions & 0 deletions client/src/js/models/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ define(['backbone', 'collections/components',
SCREENINGCOLLECTVALUE: '',
STRATEGYOPTION: '',
SHAPE: '',
SMILES: '',
SPACEGROUP: '',
SYMBOL: '',
THEORETICALDENSITY: '',
Expand Down Expand Up @@ -163,6 +164,10 @@ define(['backbone', 'collections/components',
required: false,
pattern: 'number'
},
SMILES: {
required: false,
pattern: 'smiles'
},

PACKINGFRACTION: {
required: false,
Expand Down
Loading

0 comments on commit c044628

Please sign in to comment.