Skip to content

Commit

Permalink
Merge branch 'master' into improvement/lims-1564/remove-unused-depend…
Browse files Browse the repository at this point in the history
…encies
  • Loading branch information
ndg63276 authored Jan 10, 2025
2 parents 71f1165 + 3684b32 commit b8d6e81
Show file tree
Hide file tree
Showing 49 changed files with 386 additions and 326 deletions.
13 changes: 7 additions & 6 deletions api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@
$enabled_container_types = array();

# Zocalo message broker credentials - Set to empty string to disable
$zocalo_server = 'tcp://activemq.server.ac.uk';
$zocalo_username = 'foo';
$zocalo_password = 'bar';

# Primary Zocalo entry point for recipe submission
$zocalo_mx_reprocess_queue = '/queue/zocolo.name';
$rabbitmq_zocalo_host = 'rabbitmq.server.ac.uk';
$rabbitmq_zocalo_port = 5672;
$rabbitmq_zocalo_username = 'foo';
$rabbitmq_zocalo_password = 'bar';
$rabbitmq_zocalo_vhost = 'zocalo';
$rabbitmq_zocalo_routing_key = 'processing_recipe';

# This is used to trigger Zocalo recipes on adding new Protein sequences
# Set to empty string to disable
Expand Down Expand Up @@ -381,4 +381,5 @@
# Dials server values
$dials_rest_url = "";
$dials_rest_jwt = "";
$dials_rest_url_rings = false;
?>
4 changes: 3 additions & 1 deletion api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function setupApplication($mode): Slim
$facility_courier_countries, $facility_courier_countries_nde, $facility_courier_countries_link,
$dhl_enable, $scale_grid, $scale_grid_end_date, $preset_proposal, $timezone,
$valid_components, $enabled_container_types, $ifsummary, $synchweb_version, $redirects,
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments;
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments,
$dials_rest_url_rings;
$app->contentType('application/json');
$options = $app->container['options'];
$app->response()->body(json_encode(array(
Expand All @@ -95,6 +96,7 @@ function setupApplication($mode): Slim
'synchweb_version' => $synchweb_version,
'shipping_service_app_url' => $use_shipping_service_redirect || $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null,
'shipping_service_app_url_incoming' => $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null,
'dials_rest_url_rings' => $dials_rest_url_rings,
'redirects' => $redirects
)));
});
Expand Down
16 changes: 8 additions & 8 deletions api/scripts/mtz2map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ else
fi
fi

#export CCP4_MASTER=/dls_sw/apps/ccp4/<ccp4 version>
export CCP4_MASTER=$5
export CINCL=$CCP4_MASTER/include
export CLIBD=$CCP4_MASTER/lib/data

export CCP4_SCR=/tmp
export root=$CCP4_MASTER/bin

if [ $3 == 'dimple' -o $3 == 'mrbump' ]; then

if [ -f $4 ]; then
Expand All @@ -28,14 +36,6 @@ else
fi
fi

#export CCP4_MASTER=/dls_sw/apps/ccp4/<ccp4 version>
export CCP4_MASTER=$5
export CINCL=$CCP4_MASTER/include
export CLIBD=$CCP4_MASTER/lib/data

export CCP4_SCR=/tmp
export root=$CCP4_MASTER/bin

if [ $3 == 'dimple' ]; then

if $root/mtzinfo $mtz | grep -q PH2FOFCWT; then
Expand Down
11 changes: 3 additions & 8 deletions api/src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,8 @@ function _update_user()
$person = $this->userData->getUser($this->user->personId, $this->proposalid, $this->arg('PERSONID'));
$person = $person[0];
$this->_output((array) $person);
$laboratory = null;
if ($person['LABORATORYID'])
{
$laboratory = $this->userData->getLaboratory($person['LABORATORYID'])[0];
}

$this->userData->updateLaboratory(
$laboratoryId = $this->userData->updateLaboratory(
$this->arg('PERSONID'),
$this->argOrNull('LABNAME'),
$this->argOrNull('ADDRESS'),
Expand All @@ -290,7 +285,7 @@ function _update_user()
$this->argOrNull('COUNTRY'),
$person['LABORATORYID']
);
$laboratory = $this->userData->getLaboratory($person['LABORATORYID']);
$laboratory = $this->userData->getLaboratory($laboratoryId);
$this->_output((array) $laboratory[0]);
}

Expand Down Expand Up @@ -362,4 +357,4 @@ function _update_permission()
);
$this->_output(array('TYPE' => $this->arg('TYPE'), 'DESCRIPTION' => $desc));
}
}
}
1 change: 1 addition & 0 deletions api/src/Model/Services/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ function updateLaboratory($personId, $labName, $labAddress, $city, $postcode, $c
->whereIdEquals("personid", $personId)
->update("person");
}
return $laboratoryId;
}

function addGroupUser($personId, $gid)
Expand Down
8 changes: 3 additions & 5 deletions api/src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function auth($require_staff)
{
$auth = $this->staff;

// Beamline Sample Registration
}
// Barcode Scanners
else if ($this->bcr() && !$this->user->loginId)
Expand Down Expand Up @@ -1037,9 +1036,9 @@ function get_visit_processed_dir($dc, $location)

function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
{
global $zocalo_mx_reprocess_queue;
global $rabbitmq_zocalo_vhost;

if (isset($zocalo_mx_reprocess_queue))
if (isset($rabbitmq_zocalo_vhost))
{
// Send job to processing queue
$zocalo_message = array(
Expand All @@ -1048,7 +1047,7 @@ function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
),
'parameters' => $parameters,
);
$this->_send_zocalo_message($zocalo_mx_reprocess_queue, $zocalo_message, $error_code);
$this->_send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_code);
}
}

Expand All @@ -1074,7 +1073,6 @@ function _send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_co

try
{
error_log("Sending message" . var_export($zocalo_message, true));
$queue = new Queue($rabbitmq_zocalo_host, $rabbitmq_zocalo_port, $rabbitmq_zocalo_username, $rabbitmq_zocalo_password, $rabbitmq_zocalo_vhost);
$queue->send($zocalo_message, $rabbitmq_zocalo_routing_key);
}
Expand Down
8 changes: 4 additions & 4 deletions api/src/Page/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ function _beamlines()
$pdb = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, $replace as bl, count(p.pdbentryid) as count
FROM pdbentry p
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY $replace, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

$isp = $this->db->pq("SELECT TO_CHAR(p.pdbdate, 'YYYY') as year, CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END as bl, count(p.pdbentryid) as count
FROM pdbentry p
Expand All @@ -284,8 +284,8 @@ function _beamlines()
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE p.pdbdate > TO_DATE('2010-05', 'YYYY-MM')
GROUP BY CASE WHEN p.autoprocprogramid > 0 THEN UPPER(s.beamlinename) ELSE $replace END, TO_CHAR(p.pdbdate, 'YYYY')
ORDER BY TO_CHAR(p.pdbdate, 'YYYY')");
GROUP BY bl, year
ORDER BY year, bl");

foreach ($pdb as $i => &$s) {
$s['COUNT'] = intval(($s['COUNT']));
Expand Down
38 changes: 28 additions & 10 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class DC extends Page
array('/dat/:id', 'get', '_plot'),
);

const EVTOA = 12398.4198;

# ------------------------------------------------------------------------
# Data Collection AJAX Requests
# This is pretty crazy, it will return unioned data collections, energy
Expand Down Expand Up @@ -422,9 +424,12 @@ function _data_collections($single = null)
dc.transmission,
dc.axisrange,
dc.wavelength,
".self::EVTOA."/dc.wavelength as energy,
dc.comments,
1 as epk,
1 as ein,
1 as wpk,
1 as win,
dc.xtalsnapshotfullpath1 as x1,
dc.xtalsnapshotfullpath2 as x2,
dc.xtalsnapshotfullpath3 as x3,
Expand Down Expand Up @@ -556,9 +561,12 @@ function _data_collections($single = null)
min(dc.transmission) as transmission,
min(dc.axisrange) as axisrange,
min(dc.wavelength) as wavelength,
".self::EVTOA."/min(dc.wavelength) as energy,
min(dc.comments) as comments,
1 as epk,
1 as ein,
1 as wpk,
1 as win,
min(dc.xtalsnapshotfullpath1) as x1,
min(dc.xtalsnapshotfullpath2) as x2,
min(dc.xtalsnapshotfullpath3) as x3,
Expand Down Expand Up @@ -705,17 +713,20 @@ function _data_collections($single = null)
es.energyscanid,
1,
es.element,
es.peakfprime,
es.peakfprime as resolution,
es.exposuretime,
es.axisposition,
es.peakfdoubleprime,
es.peakfdoubleprime as numimg,
es.starttime as st,
es.transmissionfactor,
es.inflectionfprime,
es.inflectionfdoubleprime,
es.inflectionfprime as axisrange,
es.inflectionfdoubleprime as wavelength,
1 as energy,
es.comments,
es.peakenergy,
es.inflectionenergy,
".self::EVTOA."/es.peakenergy as wpk,
".self::EVTOA."/es.inflectionenergy as win,
'A',
'A',
'A',
Expand Down Expand Up @@ -805,10 +816,13 @@ function _data_collections($single = null)
TO_CHAR(xrf.starttime, 'DD-MM-YYYY HH24:MI:SS') as st,
xrf.beamtransmission,
1,
xrf.energy,
".self::EVTOA."/xrf.energy as wavelength,
xrf.energy as energy,
xrf.comments,
1,
1,
1 as wpk,
1 as win,
'A',
'A',
'A',
Expand Down Expand Up @@ -899,9 +913,12 @@ function _data_collections($single = null)
1,
1,
1,
1 as energy,
'A',
1,
1,
1 as wpk,
1 as win,
r.xtalsnapshotbefore,
r.xtalsnapshotafter,
'A',
Expand Down Expand Up @@ -974,7 +991,7 @@ function _data_collections($single = null)

// Data collections
if ($dc['TYPE'] == 'data') {
$nf = array(1 => array('AXISSTART', 'CHISTART', 'PHI', 'OVERLAP'), 2 => array('RESOLUTION', 'TRANSMISSION', 'AXISRANGE', 'TOTALDOSE'), 4 => array('WAVELENGTH', 'EXPOSURETIME'));
$nf = array(0 => array('ENERGY'), 1 => array('AXISSTART', 'CHISTART', 'PHI', 'OVERLAP'), 2 => array('RESOLUTION', 'TRANSMISSION', 'AXISRANGE', 'TOTALDOSE'), 4 => array('WAVELENGTH', 'EXPOSURETIME'));

$dc['DIRFULL'] = $dc['DIR'];
$dc['DIR'] = preg_replace('/.*\/' . $this->arg('prop') . '-' . $dc['VN'] . '\//', '', $dc['DIR']);
Expand All @@ -993,9 +1010,10 @@ function _data_collections($single = null)
$dc['DCT'] = 'Data Collection';
}

if ($dc['DCT'] == 'Mesh')
if ($dc['DCT'] == 'Mesh' || $dc['DCT'] == 'Mesh3D' ||
($dc['DCT'] != 'Serial Fixed' && $dc['DCT'] != 'Serial Jet' && $dc['AXISRANGE'] == 0 && $dc['NI'] > 1)
) {
$dc['DCT'] = 'Grid Scan';
if ($dc['DCT'] != 'Serial Fixed' && $dc['DCT'] != 'Serial Jet' && $dc['AXISRANGE'] == 0 && $dc['NI'] > 1) {
$dc['TYPE'] = 'grid';
}
//$this->profile('dc');
Expand All @@ -1010,12 +1028,12 @@ function _data_collections($single = null)

$dc['FILETEMPLATE'] = preg_replace('/.*\/' . $this->arg('prop') . '-' . $dc['VN'] . '\//', '', $dc['FILETEMPLATE']);

$nf = array(2 => array('EXPOSURETIME', 'AXISSTART', 'RESOLUTION', 'TRANSMISSION'));
$nf = array(1 => array('EPK', 'EIN'), 2 => array('AXISRANGE', 'WAVELENGTH', 'EXPOSURETIME', 'AXISSTART', 'RESOLUTION', 'TRANSMISSION', 'NUMIMG'), 5 => array('WPK', 'WIN'));
$this->profile('edge');

// MCA Scans
} else if ($dc['TYPE'] == 'mca') {
$nf = array(2 => array('EXPOSURETIME', 'WAVELENGTH', 'TRANSMISSION'));
$nf = array(0 => array('ENERGY'), 2 => array('EXPOSURETIME', 'TRANSMISSION'), 4 => array('WAVELENGTH'));
$dc['DIRFULL'] = $dc['DIR'];
$dc['DIR'] = preg_replace('/.*\/\d\d\d\d\/\w\w\d+-\d+\//', '', $dc['DIR']);

Expand Down
10 changes: 4 additions & 6 deletions api/src/Page/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ function _download_visit()
$this->_error('There doesnt seem to be a data archive available for this visit');
}

# ------------------------------------------------------------------------
# Download mtz/log file for Fast DP / XIA2
# TODO: Delete me

# This method either returns a list of plots from MX auto processing tools (n_obs, n_uniq, completeness etc.)
# Or returns a specific plot based on auto processing attachment id (aid).
# Individual plotly format Graphs can be returned via an aid, but will not be included in the list of plots (as their format is different)
Expand Down Expand Up @@ -468,14 +466,14 @@ function _get_autoproc_archive()

$aps = $this->db->union(
array(
"SELECT app.autoprocprogramid, app.processingprograms, app.processingstatus
"SELECT app.autoprocprogramid, app.processingprograms, app.processingstatus, dc.imageprefix, dc.datacollectionnumber
FROM autoprocintegration api
INNER JOIN autoprocprogram app ON api.autoprocprogramid = app.autoprocprogramid
INNER JOIN datacollection dc ON dc.datacollectionid = api.datacollectionid
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE s.proposalid=:1 AND app.autoprocprogramid=:2",
"SELECT app.autoprocprogramid, app.processingprograms, app.processingstatus
"SELECT app.autoprocprogramid, app.processingprograms, app.processingstatus, dc.imageprefix, dc.datacollectionnumber
FROM autoprocprogram app
INNER JOIN processingjob pj on pj.processingjobid = app.processingjobid
INNER JOIN datacollection dc ON dc.datacollectionid = pj.datacollectionid
Expand All @@ -497,7 +495,7 @@ function _get_autoproc_archive()
}

$clean_program = preg_replace('/[^A-Za-z0-9\-]/', '', $ap['PROCESSINGPROGRAMS']);
$zipName = $this->arg('AUTOPROCPROGRAMID') . '_' . $clean_program;
$zipName = $this->arg('AUTOPROCPROGRAMID') . '_' . $ap['IMAGEPREFIX'] . '_' . $ap['DATACOLLECTIONNUMBER'] . '_' . $clean_program;
$this->_streamZipFile($files, $zipName);
}

Expand Down
8 changes: 6 additions & 2 deletions api/src/Page/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ class Image extends Page
'aid' => '\d+',
'visit' => '\w+\d+-\d+',
'thresh' => '\d',
'res' => '\d',
'ice' => '\d',
);

public static $dispatch = array(array('/id/:id(/n/:n)', 'get', '_xtal_image'),
array('/diff/id/:id(/f/:f)(/n/:n)', 'get', '_diffraction_image'),
array('/di/id/:id(/thresh/:thresh)(/n/:n)', 'get', '_diffraction_viewer'),
array('/di/id/:id(/thresh/:thresh)(/res/:res)(/ice/:ice)(/n/:n)', 'get', '_diffraction_viewer'),
array('/cam/bl/:bl(/n/:n)', 'get', '_forward_webcam'),
array('/oav/bl/:bl(/n/:n)', 'get', '_forward_oav'),
array('/fa/fid/:id', 'get', '_fault_attachment'),
Expand Down Expand Up @@ -192,7 +194,7 @@ function _diffraction_viewer() {
}

$im = $info['LOC'] . '/' . $info['FT'];
$out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . '.jpg';
$out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . ($this->has_arg('res') ? '_res' : '') . ($this->has_arg('ice') ? '_ice' : '') . '.jpg';
global $dials_rest_url, $dials_rest_jwt;
if (!file_exists($out)) {
if (!empty($dials_rest_url) && !empty($dials_rest_jwt)) {
Expand All @@ -212,6 +214,8 @@ function _diffraction_viewer() {
'colour_scheme' => 'greyscale',
'brightness' => $this->has_arg('thresh') ? 1000 : 10,
'format' => 'png',
'resolution_rings' => array('show' => $this->has_arg('res')),
'ice_rings' => array('show' => $this->has_arg('ice')),
)
));
} else {
Expand Down
10 changes: 4 additions & 6 deletions api/src/Page/Proposal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,8 @@ function _update_autocollect_session($sessionId, $uasSessionId, $containerId, $t
$uas = new UAS($auto_user, $auto_pass);
$code = $uas->update_session($uasSessionId, $data);

if ($code == 200) {
// Update ISPyB records
if ($code == 200 || $code == 404) {
// Update ISPyB records, even if UAS says session not found
$this->db->pq("UPDATE container SET sessionid=:1 WHERE containerid=:2", array($sessionId, $containerId));
// For debugging - actually just want to return Success!
$result = array(
Expand All @@ -1216,13 +1216,11 @@ function _update_autocollect_session($sessionId, $uasSessionId, $containerId, $t
);
} else if ($code == 403) {
$this->_error('UAS Error - samples and/or investigators not valid. ISPyB/UAS Session ID: ' . $sessionId . ' / ' . $uasSessionId);
} else if ($code == 404) {
$this->_error('UAS Error - session not found in UAS, Session ID: ' . $sessionId . ' UAS Session ID: ' . $uasSessionId);
} else {
$this->_error('UAS Error - something wrong creating a session for that container ' . $containerId . ', response code was: ' . $code);
$this->_error('UAS Error - something went wrong updating a session for that container ' . $containerId . ', response code was: ' . $code);
}
} else {
error_log("Something wrong - an Auto Collect session exists but with no containers " . $sessionId);
error_log("Something went wrong - an Auto Collect session exists but with no containers " . $sessionId);

$this->_error('No valid containers on the existing Auto Collect Session id:', $sessionId);
}
Expand Down
Loading

0 comments on commit b8d6e81

Please sign in to comment.