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
6 changes: 6 additions & 0 deletions api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@
'i04' => False,
);

# puck capacity of beamlines which take pucks, sample capacity of those which take samples
$bl_capacity = array(
"i03" => array("pucks" => 37, "samples" => 0),
"i04" => array("pucks" => 37, "samples" => 0),
);

# Dials server values
$dials_rest_url = "";
$dials_rest_jwt = "";
Expand Down
4 changes: 3 additions & 1 deletion api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function setupApplication($mode): Slim
$valid_components, $enabled_container_types, $synchweb_version, $redirects,
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments,
$dials_rest_url_rings, $closed_proposal_link, $ccp4_cloud_upload_url,
$only_staff_can_assign, $industrial_prop_codes, $prop_codes_data_deleted, $container_types_with_parents;
$only_staff_can_assign, $industrial_prop_codes, $prop_codes_data_deleted, $container_types_with_parents,
$bl_capacity;
$app->contentType('application/json');
$options = $app->container['options'];
$app->response()->body(json_encode(array(
Expand Down Expand Up @@ -106,6 +107,7 @@ function setupApplication($mode): Slim
'container_types_with_parents' => $container_types_with_parents,
'industrial_prop_codes' => $industrial_prop_codes,
'prop_codes_data_deleted' => $prop_codes_data_deleted ?? array(),
'bl_capacity' => $bl_capacity,
)));
});
return $app;
Expand Down
28 changes: 23 additions & 5 deletions api/src/Controllers/AssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AssignController extends Page
{
private $assignData;

public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');
public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'sid' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');

public static $dispatch = array(
array('/assign', 'get', 'assignContainer'),
Expand All @@ -32,15 +32,24 @@ function __construct(Slim $app, $db, $user, AssignData $assignData)
function assignContainer()
{
global $only_staff_can_assign;
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
if ($this->has_arg('cid')) {
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
} else if ($this->has_arg('sid')) {
$cs = $this->assignData->getSample($this->arg('visit'), $this->arg('sid'));
} else {
$cs = array();
}
if (sizeof($cs) > 0)
{
$bl = $cs[0]['BEAMLINENAME'];
if (is_array($only_staff_can_assign) && array_key_exists($bl, $only_staff_can_assign) && $only_staff_can_assign[$bl] == true && !$this->staff) {
$this->_error("Only staff can assign containers on this beamline");
} else {
} else if ($this->has_arg('cid')) {
$this->assignData->assignContainer($cs[0], $this->arg('pos'));
$this->_output(1);
} else if ($this->has_arg('sid')) {
$this->assignData->assignSample($cs[0], $this->arg('pos'));
$this->_output(1);
}
}
else
Expand All @@ -52,16 +61,25 @@ function assignContainer()
function unassignContainer()
{
global $only_staff_can_assign;
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
if ($this->has_arg('cid')) {
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
} else if ($this->has_arg('sid')) {
$cs = $this->assignData->getSample($this->arg('visit'), $this->arg('sid'));
} else {
$cs = array();
}

if (sizeof($cs) > 0)
{
$bl = $cs[0]['BEAMLINENAME'];
if (is_array($only_staff_can_assign) && array_key_exists($bl, $only_staff_can_assign) && $only_staff_can_assign[$bl] == true && !$this->staff) {
$this->_error("Only staff can unassign containers on this beamline");
} else {
} else if ($this->has_arg('cid')) {
$this->assignData->unassignContainer($cs[0]);
$this->_output(1);
} else if ($this->has_arg('sid')) {
$this->assignData->unassignSample($cs[0]);
$this->_output(1);
}
}
else
Expand Down
34 changes: 34 additions & 0 deletions api/src/Downstream/Type/Dimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ function results() {
$dat['PKLIST'] = $pklist;
}

$dat['ANODE_PEAKS'] = $this->_get_anode_peaks($this->process['PARAMETERS']['scaling_id']);

$results = new DownstreamResult($this);
$results->data = $dat;

Expand Down Expand Up @@ -165,4 +167,36 @@ function mapmodel($n = 0, $map = false) {
return $pdb['FILE'];
}
}

function _get_anode_peaks($scaling_id) {

$peaks = array();
$plot = array();

$blobs = $this->db->pq(
"SELECT mb.x, mb.y, mb.z, mb.height, mb.occupancy,
mb.nearestatomdistance, mb.nearestatomname, mb.nearestatomchainid,
mb.nearestatomresname, mb.nearestatomresseq
FROM mxmrrunblob mb
INNER JOIN mxmrrun m ON mb.mxmrrunid = m.mxmrrunid
WHERE mb.maptype='anomalous' and m.autoprocscalingid=:1
ORDER BY mb.height DESC
LIMIT 10",
array($scaling_id)
);

foreach ($blobs as $n => $blob) {
array_push($peaks, array(
number_format($blob['X'], 2),
number_format($blob['Y'], 2),
number_format($blob['Z'], 2),
number_format($blob['HEIGHT'], 2),
number_format($blob['OCCUPANCY'], 1),
$blob['NEARESTATOMDISTANCE'] . ' ' . $blob['NEARESTATOMNAME'] . '_' . $blob['NEARESTATOMCHAINID']
. ':' . $blob['NEARESTATOMRESNAME'] . $blob['NEARESTATOMRESSEQ'],
));
array_push($plot, array($n+1, $blob['HEIGHT']));
}
return array('TABLE' => $peaks, 'PLOT' => $plot);
}
}
34 changes: 34 additions & 0 deletions api/src/Model/Services/AssignData.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ function getContainer($visitId, $containerId)
AND c.containerid=:2", array($visitId, $containerId));
}

function getSample($visitId, $sampleId)
{
return $this->db->pq("SELECT b.blsampleid,b.name,d.dewarid,bl.beamlinename,c.containerid,c.code FROM blsample b
INNER JOIN container c ON c.containerid = b.containerid
INNER JOIN dewar d ON d.dewarid = c.dewarid
INNER JOIN shipping s ON s.shippingid = d.shippingid
INNER JOIN blsession bl ON bl.proposalid = s.proposalid
INNER JOIN proposal p ON s.proposalid = p.proposalid
WHERE CONCAT(p.proposalcode, p.proposalnumber, '-', bl.visit_number) LIKE :1
AND b.blsampleid=:2", array($visitId, $sampleId));
}

function assignContainer($container, $location)
{
$this->updateDewar($container['DEWARID'], 'processing');
Expand All @@ -36,11 +48,27 @@ function assignContainer($container, $location)
$this->updateDewarHistory($container['DEWARID'], 'processing', $container['BEAMLINENAME'], $container['CODE'] . ' => ' . $location);
}

function assignSample($sample, $location)
{
$this->updateSample($sample['BLSAMPLEID'], $location);

$this->updateDewar($sample['DEWARID'], 'processing');

$this->updateContainerAndHistory($sample['CONTAINERID'], 'processing', $sample['BEAMLINENAME'], null);

$this->updateDewarHistory($sample['DEWARID'], 'processing', $sample['BEAMLINENAME'], $sample['NAME'] . ' => ' . $location);
}

function unassignContainer($container)
{
$this->updateContainerAndHistory($container['CONTAINERID'], 'at facility', '', '');
}

function unassignSample($sample)
{
$this->updateSample($sample['BLSAMPLEID'], null);
}

function updateContainerAndHistory($containerId, $status, $beamlineName, $location)
{
$this->updateContainer($containerId, $status, $beamlineName, $location);
Expand All @@ -61,6 +89,12 @@ function updateContainer($containerId, $status, $beamlineName, $location)
WHERE containerid=:4", array($beamlineName, $location, $status, $containerId));
}

function updateSample($sampleId, $location)
{
$this->db->pq("UPDATE blsample SET isinsamplechanger=:1
WHERE blsampleid=:2", array($location, $sampleId));
}

function getDewar($dewarId, $proposalId, $visitId)
{
$where = "p.proposalid=:1";
Expand Down
14 changes: 13 additions & 1 deletion api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class Sample extends Page
'BEAMLINENAME' => '[\w\-]+',
'SOURCE' => '[\w\-]+',

'assigned' => '[\w\-]+',
'unassigned' => '[\w\-]+',
'queued' => '\d',
'UNQUEUE' => '\d',
'nodata' => '\d',
Expand Down Expand Up @@ -1145,6 +1147,16 @@ function _samples()
array_push($args, $sessionid);
}

if ($this->has_arg('assigned')) {
$where .= " AND d.dewarstatus LIKE 'processing' AND b.isinsamplechanger > 0 AND c.beamlinelocation LIKE :" . (sizeof($args) + 1);
array_push($args, $this->arg('assigned'));
}

if ($this->has_arg('unassigned')) {
$where .= " AND b.isinsamplechanger is null AND c.beamlinelocation=:" . (sizeof($args) + 1);
array_push($args, $this->arg('unassigned'));
}

// Search
if ($this->has_arg('s')) {
$st = sizeof($args) + 1;
Expand Down Expand Up @@ -1219,7 +1231,7 @@ function _samples()
, 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
, count(distinct dc.dataCollectionId) as dcc, b.isinsamplechanger

FROM blsample b

Expand Down
10 changes: 9 additions & 1 deletion client/src/css/partials/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@ li:last-child .visit_users {
display: none;
overflow: auto;

.larger {
font-size: 14px;
}

.dcap {
padding: 1% 1% 0 1%;

Expand Down Expand Up @@ -895,6 +899,10 @@ li:last-child .visit_users {
}
}

&.align_center td {
text-align: center;
}

}


Expand Down Expand Up @@ -997,7 +1005,7 @@ li:last-child .visit_users {
height: auto;
}

.plot_dimple {
.plot_dimple, .plot_anode {
width: 70%;
float: right;

Expand Down
7 changes: 1 addition & 6 deletions client/src/js/config_sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
"production": false,

"pucks": {
"i02": 10,
"i03": 23,
"i04": 37,
"i04-1": 9,
"i24": 9,
"i23": 4
"moved to": "config.php"
},

"_gsMajorAxisOrientation" : "Determines whether the major grid scan axis determines the orientation of the view",
Expand Down
Loading
Loading