Skip to content

Commit fcc4f4b

Browse files
ndg63276Mark Williams
andauthored
LIMS-1759: Add pages to create and view ligands (#957)
* LIMS-1759: Add pages to add/view/list ligands, add PDBS, and add to samples * LIMS-1759: Add ligands to samples in plates * LIMS-1759: Fix bug where ligands were added multiple times * LIMS-1759: Fix error with too few args --------- Co-authored-by: Mark Williams <[email protected]>
1 parent 5b91a20 commit fcc4f4b

File tree

31 files changed

+1296
-47
lines changed

31 files changed

+1296
-47
lines changed

api/src/Database/Type/MySQL.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class MySQL extends DatabaseParent {
135135
'BLSampleImageAutoScoreClass',
136136
'BLSampleImage_has_AutoScoreClass',
137137

138+
'Ligand',
139+
'BLSample_has_Ligand',
140+
'Ligand_has_PDB',
141+
138142
// Queuing
139143
'ContainerQueueSample',
140144
'ContainerQueue',

api/src/Page/DC.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DC extends Page
1919
'aid' => '\d+',
2020
'pjid' => '\d+',
2121
'pid' => '\d+',
22+
'lid' => '\d+',
2223
'h' => '\d\d',
2324
'dmy' => '\d\d\d\d\d\d\d\d',
2425
'ssid' => '\d+',
@@ -259,6 +260,16 @@ function _data_collections($single = null)
259260
array_push($args, $this->arg('pid'));
260261
}
261262

263+
# Ligands
264+
} else if ($this->has_arg('lid')) {
265+
$info = $this->db->pq("SELECT ligandid FROM ligand l WHERE l.ligandid=:1", array($this->arg('lid')));
266+
267+
foreach (array('dc', 'es', 'r', 'xrf') as $i => $t) {
268+
$extj[$i] .= " INNER JOIN blsample_has_ligand bhl ON bhl.blsampleid = smp.blsampleid";
269+
$sess[$i] = 'bhl.ligandid=:' . (sizeof($args) + 1);
270+
array_push($args, $this->arg('lid'));
271+
}
272+
262273
# Processing job
263274
} else if ($this->has_arg('PROCESSINGJOBID')) {
264275
$info = $this->db->pq('SELECT processingjobid

api/src/Page/Proposal.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Proposal extends Page
3737
'SHIPPINGID' => '\d+',
3838
'LABCONTACTID' => '\d+',
3939
'DATACOLLECTIONID' => '\d+',
40+
'LIGANDID' => '\d+',
4041

4142
// proposal
4243
'PROPOSALCODE' => '\w+',
@@ -900,6 +901,7 @@ function _lookup()
900901
'SHIPPINGID' => 'sh.shippingid',
901902
'LABCONTACTID' => 'lc.labcontactid',
902903
'DATACOLLECTIONID' => 'dc.datacollectionid',
904+
'LIGANDID' => 'l.ligandid',
903905
);
904906

905907
$field = null;
@@ -958,6 +960,7 @@ function _lookup()
958960
LEFT OUTER JOIN container c ON c.dewarid = d.dewarid
959961
960962
LEFT OUTER JOIN labcontact lc ON lc.proposalid = p.proposalid
963+
LEFT OUTER JOIN ligand l ON l.proposalid = p.proposalid
961964
$where
962965
", $args);
963966

api/src/Page/Sample.php

Lines changed: 277 additions & 30 deletions
Large diffs are not rendered by default.

api/src/Page/Shipment.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Shipment extends Page
2121
'sid' => '\d+',
2222
'lcid' => '\d+',
2323
'pid' => '\d+',
24+
'lid' => '\d+',
2425
'iid' => '\d+',
2526

2627

@@ -2276,6 +2277,14 @@ function _get_all_containers()
22762277
array_push($args, $this->arg('pid'));
22772278
}
22782279

2280+
if ($this->has_arg('lid')) {
2281+
$join .= ' LEFT OUTER JOIN blsample_has_ligand bhl ON bhl.blsampleid = s.blsampleid';
2282+
$where .= ' AND bhl.ligandid=:' . (sizeof($args) + 1);
2283+
$totalQuery->joinClause("LEFT OUTER JOIN blsample s ON s.containerid = c.containerid");
2284+
$totalQuery->joinClause("LEFT OUTER JOIN blsample_has_ligand bhl ON bhl.blsampleid = s.blsampleid");
2285+
array_push($args, $this->arg('lid'));
2286+
}
2287+
22792288
if ($this->has_arg('assigned')) {
22802289
$where .= " AND d.dewarstatus LIKE 'processing' AND c.samplechangerlocation > 0";
22812290
$totalQuery->joinClause("INNER JOIN dewar d ON d.dewarid = c.dewarid");
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
define(['underscore', 'backbone.paginator', 'models/ligand'], function(_, PageableCollection, Ligand) {
2+
3+
return PageableCollection.extend({
4+
model: Ligand,
5+
mode: 'server',
6+
url: '/sample/ligands',
7+
8+
state: {
9+
pageSize: 15,
10+
},
11+
12+
parseState: function(r, q, state, options) {
13+
return { totalRecords: r.total }
14+
},
15+
16+
parseRecords: function(r, options) {
17+
return r.data
18+
},
19+
20+
initialize: function(collection, options) {
21+
this.fetched = false
22+
this.on('sync', this.setFetched, this)
23+
if (options && options.pmodel) {
24+
this.pmodel = options.pmodel
25+
this.listenTo(this, 'change add remove', this._update_ligand_ids)
26+
this.listenTo(this.pmodel, 'sync', this._add_ligands)
27+
this._add_ligands()
28+
}
29+
},
30+
31+
setFetched: function() {
32+
if (this.fetched) return
33+
this.fetched = true
34+
this.trigger('reset')
35+
},
36+
37+
_update_ligand_ids: function() {
38+
var ligs = this.slice(0)
39+
var flds = {
40+
LIGANDIDS: _.map(ligs, function(m) { return m.get('LIGANDID') }),
41+
LIGANDNAMES: _.map(ligs, function(m) { return m.get('NAME') }),
42+
}
43+
this.pmodel.set(flds)
44+
},
45+
46+
_add_ligands: function() {
47+
var ids = this.pmodel.get('LIGANDIDS') || []
48+
var nas = this.pmodel.get('LIGANDNAMES') || []
49+
var ligs = _.map(ids, function(id, i) {
50+
return {
51+
LIGANDID: id,
52+
NAME: nas[i],
53+
}
54+
})
55+
this.reset(ligs)
56+
},
57+
})
58+
})

client/src/js/models/ligand.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
define(['backbone', 'markdown'], function(Backbone, markdown) {
2+
3+
return Backbone.Model.extend({
4+
idAttribute: 'LIGANDID',
5+
urlRoot: '/sample/ligands',
6+
7+
validation: {
8+
NAME: {
9+
required: true,
10+
pattern: 'wwdash',
11+
},
12+
SMILES: {
13+
required: false,
14+
pattern: 'smiles'
15+
},
16+
LIBRARYNAME: {
17+
required: false,
18+
pattern: 'wwdash',
19+
},
20+
LIBRARYBATCHNUMBER: {
21+
required: false,
22+
pattern: 'wwdash',
23+
},
24+
PLATEBARCODE: {
25+
required: false,
26+
pattern: 'wwdash',
27+
},
28+
SOURCEWELL: {
29+
required: false,
30+
pattern: 'wwdash',
31+
},
32+
},
33+
})
34+
35+
})

client/src/js/models/sample.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
define(['backbone', 'collections/components',
1+
define(['backbone', 'collections/components', 'collections/ligands',
22
'utils/experimentkinds',
3-
'utils/radiationsensitivity'], function(Backbone, Components, EXP, RS) {
3+
'utils/radiationsensitivity'], function(Backbone, Components, Ligands, EXP, RS) {
44

55
return Backbone.Model.extend({
66
idAttribute: 'BLSAMPLEID',
@@ -10,6 +10,7 @@ define(['backbone', 'collections/components',
1010
initialize: function(attrs, options) {
1111
var addPrimary = (options && options.addPrimary) || (this.collection && this.collection.state.addPrimary)
1212
this.set('components', new Components(null, { pmodel: this, addPrimary: addPrimary }))
13+
this.set('ligands', new Ligands(null, { pmodel: this }))
1314
this.updateScreeningOptions()
1415

1516
this.listenTo(this, 'change:EXPERIMENTKIND', this.updateExpKind)
@@ -105,6 +106,8 @@ define(['backbone', 'collections/components',
105106
INITIALSAMPLEGROUP: '',
106107
COMPONENTIDS: [],
107108
COMPONENTAMOUNTS: [],
109+
LIGANDIDS: [],
110+
LIGANDNAMES: [],
108111
X: null,
109112
Y: null,
110113
Z: null,

client/src/js/modules/samples/collections/pdbs.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ define(['backbone', 'modules/samples/models/pdb'], function(Backbone, PDB) {
22

33
return Backbone.Collection.extend({
44
model: PDB,
5-
url: function() { return '/sample/pdbs'+(this.pid ? '/pid/'+this.pid : '') },
5+
url: function() { return '/sample/pdbs'+(this.pid ? '/pid/'+this.pid : '')+(this.lid ? '/lid/'+this.lid : '') },
66

77
initialize: function(models, options) {
8-
if (options) this.pid = options.pid
8+
if (options) {
9+
this.pid = options.pid
10+
this.lid = options.lid
11+
}
912
},
1013

1114
opts: function() {
@@ -14,4 +17,4 @@ define(['backbone', 'modules/samples/models/pdb'], function(Backbone, PDB) {
1417

1518
})
1619

17-
})
20+
})
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<template>
2+
<section>
3+
<marionette-view
4+
v-if="ready"
5+
:key="$route.fullPath"
6+
:options="options"
7+
:fetch-on-load="true"
8+
:mview="mview"
9+
:breadcrumbs="bc"
10+
/>
11+
</section>
12+
</template>
13+
14+
<script>
15+
import MarionetteView from 'app/views/marionette/marionette-wrapper.vue'
16+
import AddLigandView from 'modules/samples/views/ligandadd'
17+
import Ligand from 'models/ligand'
18+
// Allow us to map store values to local computed properties
19+
import { mapGetters } from 'vuex'
20+
21+
export default {
22+
name: 'LigandAddWrapper',
23+
components: {
24+
'marionette-view': MarionetteView
25+
},
26+
data: function() {
27+
return {
28+
ready: false,
29+
mview: null,
30+
model: null,
31+
bc : [],
32+
title: '' // Used as a data property so we can report errors ok
33+
}
34+
},
35+
computed: {
36+
// Don't need to pass any options - it's a plain view
37+
options: function() {
38+
return {
39+
model: this.model
40+
}
41+
},
42+
...mapGetters('proposal', {
43+
proposalType: 'currentProposalType'
44+
})
45+
},
46+
created: function() {
47+
this.title = 'Ligand'
48+
49+
this.bc = [{ title: this.title+'s', url: '/'+this.title.toLowerCase()+'s' }]
50+
51+
// Are we allowed to add?
52+
if (!this.checkPermissions()) return
53+
54+
this.bc.push({ title: 'Add '+this.title })
55+
56+
this.mview = AddLigandView
57+
58+
// We have no need to wait for proposal lookups here
59+
this.ready = true
60+
},
61+
methods: {
62+
checkPermissions: function() {
63+
if (app.proposal && app.proposal.get('ACTIVE') != 1) {
64+
app.alert({ title: 'Proposal Not Active', message: 'This proposal is not active so new '+this.title+'s cannot be added'} )
65+
return false
66+
}
67+
return true
68+
},
69+
}
70+
}
71+
</script>

0 commit comments

Comments
 (0)