Skip to content

Commit

Permalink
Merge branch 'master' into improvement/LIMS-1528/fix-sorting-on-old-s…
Browse files Browse the repository at this point in the history
…ummary-page
  • Loading branch information
ndg63276 authored Dec 16, 2024
2 parents 0cd5632 + 7eb2aab commit 32f150a
Show file tree
Hide file tree
Showing 49 changed files with 326 additions and 303 deletions.
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
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
4 changes: 2 additions & 2 deletions api/src/Page/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Contact extends Page
{

public static $arg_list = array('CARDNAME' => '([\w\s\-])+',
'FAMILYNAME' => '([\w\-])+',
'GIVENNAME' => '([\w\-])+',
'FAMILYNAME' => '([\w\s\-])+',
'GIVENNAME' => '([\w\s\-])+',
'PHONENUMBER' => '.*',
'EMAILADDRESS' => '.*',
'LABNAME' => '([\w\s\-])+',
Expand Down
46 changes: 32 additions & 14 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 @@ -121,11 +123,11 @@ function _data_collections($single = null)

$where = '';
if ($this->arg('t') == 'sc')
$where = ' AND (dc.overlap != 0 OR ifnull(et.name, dcg.experimenttype) = "Screening")';
$where = ' AND (dc.overlap != 0 OR ifnull(et.name, dcg.experimenttype) in ("Screening", "Characterization"))';
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 ifnull(et.name, dcg.experimenttype) != "Screening"';
$where = ' AND dc.overlap = 0 AND dc.axisrange > 0 AND dc.numberOfImages > 1 AND ifnull(et.name, dcg.experimenttype) not in ("Screening", "Characterization")';
} else if ($this->arg('t') == 'edge') {
$where2 = '';
} else if ($this->arg('t') == 'mca') {
Expand All @@ -139,11 +141,11 @@ function _data_collections($single = null)
$where2 = " AND es.comments LIKE '%_FLAG_%'";
$where4 = " AND xrf.comments LIKE '%_FLAG_%'";
} else if ($this->arg('t') == 'ap') {
$where = ' AND app.processingstatus = 1';
$where = " AND ifnull(et.name, dcg.experimenttype) not in ('Screening', 'Characterization') AND app.processingstatus = 1";
$extj[0] .= "INNER JOIN autoprocintegration ap ON dc.datacollectionid = ap.datacollectionid
INNER JOIN autoprocprogram app ON app.autoprocprogramid = ap.autoprocprogramid";
} else if ($this->arg('t') == 'ph') {
$where = " AND app.processingstatus = 1 AND app.processingprograms in ('big_ep', 'fast_ep')";
$where = " AND ifnull(et.name, dcg.experimenttype) not in ('Screening', 'Characterization') AND app.processingstatus = 1 AND app.processingprograms in ('big_ep', 'fast_ep')";
$extj[0] .= "INNER JOIN processingjob pj ON dc.datacollectionid = pj.datacollectionid
INNER JOIN autoprocprogram app ON app.processingjobid = pj.processingjobid";
} else if ($this->arg('t') == 'err') {
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
15 changes: 12 additions & 3 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ 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 pj.automatic = 1
WHERE $where AND api.autoprocintegrationid IS NULL
AND app.processingprograms NOT IN ('$filter')",
),
$ids
Expand Down Expand Up @@ -900,11 +900,17 @@ private function _autoprocessing_query_builder($where, $group, $order = '') {
ap.refinedcell_alpha as cell_al,
ap.refinedcell_beta as cell_be,
ap.refinedcell_gamma as cell_ga,
(SELECT COUNT(api1.autoprocintegrationid) FROM autoprocintegration api1 WHERE api1.autoprocprogramid = app.autoprocprogramid) as imagesweepcount,
(SELECT COUNT(api1.autoprocintegrationid) FROM autoprocintegration api1 WHERE api1.autoprocprogramid = app.autoprocprogramid) as imagesweepcount,
app.processingstatus,
app.processingmessage,
count(distinct pjis.datacollectionid) as dccount,
max(pjis.processingjobid) as processingjobid,
(SELECT IFNULL(blsg.name, bls.name) FROM processingjobparameter pjp
LEFT OUTER JOIN blsample bls ON pjp.parametervalue = bls.blsampleid
LEFT OUTER JOIN blsamplegroup blsg ON pjp.parametervalue = blsg.blsamplegroupid
WHERE pjp.processingjobid = pj.processingjobid
AND pjp.parameterkey in ('sample_id', 'sample_group_id')
) as groupname,
pj.automatic";

$from = "FROM autoprocintegration api";
Expand Down Expand Up @@ -954,7 +960,7 @@ private function _format_auto_processing_result($table_rows, $messages_result) {
'cell_ga',
);
$resolution_data = array('rlow', 'rhigh');
$returned_keys = array('PROCESSINGJOBID', 'IMAGESWEEPCOUNT', 'DCCOUNT', 'TYPE', 'PROCESSINGSTATUS', 'PROCESSINGMESSAGE');
$returned_keys = array('PROCESSINGJOBID', 'IMAGESWEEPCOUNT', 'DCCOUNT', 'TYPE', 'PROCESSINGSTATUS', 'PROCESSINGMESSAGE', 'GROUPNAME');

foreach($table_rows as &$row) {
if (!array_key_exists($row['AUTOPROCPROGRAMID'], $formatted_result)) {
Expand All @@ -975,6 +981,9 @@ private function _format_auto_processing_result($table_rows, $messages_result) {
$prefix = preg_match('/multi/', $value) ? '' : 'multi-';
$value = $row['DCCOUNT'] . 'x ' . $prefix . $value;
}
if ($row['GROUPNAME']) {
$value .= ' ('.$row['GROUPNAME'].')';
}
}


Expand Down
16 changes: 16 additions & 0 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class Sample extends Page
array('/pdbs(/pid/:pid)', 'get', '_get_pdbs'),
array('/pdbs', 'post', '_add_pdb'),
array('/pdbs(/:pdbid)', 'delete', '_remove_pdb'),
array('/pdbs/download/:pdbid', 'get', '_download_pdb'),

array('/concentrationtypes', 'get', '_concentration_types'),
array('/componenttypes', 'get', '_component_types'),
Expand Down Expand Up @@ -2062,6 +2063,21 @@ function _get_pdbs()
$this->_output($rows);
}

# ------------------------------------------------------------------------
# Download a pdb file
function _download_pdb()
{
if (!$this->has_arg('pdbid'))
$this->_error('No PDB id specified');

$pdb = $this->db->pq("SELECT name, contents FROM pdb WHERE pdbid = :1", array($this->arg('pdbid')));
$pdb = $pdb[0];

header('Content-Type:text/plain');
header('Content-Disposition:attachment;filename='.$pdb['NAME']);
print $pdb['CONTENTS'];
}

# ------------------------------------------------------------------------
# Add a new pdb
function _add_pdb()
Expand Down
Loading

0 comments on commit 32f150a

Please sign in to comment.