-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSampleDB.html
More file actions
361 lines (245 loc) · 21.7 KB
/
Copy pathSampleDB.html
File metadata and controls
361 lines (245 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Sample Database — PYME 20.02.12 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="PYME package" href="api/PYME.html" />
<link rel="prev" title="TIFF support in PYME" href="tiff_handling.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> PYME
<img src="_static/pymeLogo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
20.02.12
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Installation</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="Installation/InstallationWithAnaconda.html">Installation of PYME on 64 bit Windows, OSX, or Linux</a></li>
<li class="toctree-l1"><a class="reference internal" href="Installation/InstallationFromSource.html">Installation for development or instrument control</a></li>
</ul>
<p class="caption"><span class="caption-text">User Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="PYMEAcquire.html"><strong>PYMEAcquire</strong> - Instrument control and simulation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Analysis.html"><strong>dh5view</strong> - Image Data Analysis and Viewing</a></li>
<li class="toctree-l1"><a class="reference internal" href="VisGUI.html"><strong>VisGUI</strong> - Visualising Localization Data Sets</a></li>
<li class="toctree-l1"><a class="reference internal" href="component_programs.html">Common Tasks</a></li>
<li class="toctree-l1"><a class="reference internal" href="LocalisationAnalysis.html">Analysing Localisation Microscopy data</a></li>
</ul>
<p class="caption"><span class="caption-text">Development / Hacking</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="hacking.html">Extending PYME and writing plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="hacking.html#technical-details">Technical Details</a></li>
<li class="toctree-l1"><a class="reference internal" href="hacking.html#api-documentation">API Documentation</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">PYME</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="hacking.html">Extending PYME and writing plugins</a> »</li>
<li>The Sample Database</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="the-sample-database">
<h1>The Sample Database<a class="headerlink" href="#the-sample-database" title="Permalink to this headline">¶</a></h1>
<p>The sample database is a database system which can be used in conjunction with PYMEAcquire to record information about
sample preparation, labelling, etc for every image that is acquired. The database has a web interface, and is searchable,
allowing data matching various search keys to be easily located.</p>
<div class="section" id="structure-schema">
<h2>Structure / Schema<a class="headerlink" href="#structure-schema" title="Permalink to this headline">¶</a></h2>
<p>The core unit unit of the database schema is the <strong>Slide</strong>, which represents one stained coverslip (ie all preparation conditions
consistent). The slide is linked to a sample, which was conceived to represent one tissue source (a patient, a rat, a
particular passage of cell culture). Each slide has an associated species, with the <strong>Species</strong> object representing both
species and also strain (e.g. wistar for rats, HeLa, HEK293, etc for cultured cells).</p>
<p>A <strong>Slide</strong> will have one or more <strong>Labelling</strong> s which represent, e.g. the expression of a fluorescent protein,
antibody labelling with a given combination of primary and secondary antibodies, or FISH staining with a specific probe.
Each <strong>Labelling</strong> has a <strong>Dye</strong> associated with it - the long name is what the manufacturer would call it e.g.
‘Alexa Fluor 647’. For fluorescent proteins, it should ideally include enough info to uniquely identify it. The short name
is used for internal shorthand and as a key in other parts of our software. It should not include spaces - e.g. ‘A647’.
The <em>spectraDBName</em> is the name of the dye in the Chroma spectra viewer, to facilitate automatic retrieval of dye spectra.</p>
<p>A <strong>Slide</strong> may have one or more images associated with it. Each image represents one <em>RAW</em> data acquisition, and may
have multiple <strong>File</strong> s. One of these files will be the raw data, whilst others could be analysed results.</p>
<div class="figure" id="id5">
<img alt="_images/SampleDB_schem_no_tags.png" src="_images/SampleDB_schem_no_tags.png" />
<p class="caption"><span class="caption-text">Simplified database schema. In addition to the tables depicted, there are also Slide, Image, and File tags which can
be associated with a given Slide, Image, or File.</span></p>
</div>
</div>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>These instructions assume you are running an ubuntu linux server with python, mercurial, apache, mysql, and phpmyadmin <a class="footnote-reference" href="#id3" id="id1">[1]</a>. They should also provide a starting point for other systems. A reasonable knowledge of linux and python is assumed.</p>
<div class="section" id="part-i-basic-setup">
<h3>Part I - Basic Setup<a class="headerlink" href="#part-i-basic-setup" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">Using <code class="docutils literal notranslate"><span class="pre">apt-get</span></code> or <code class="docutils literal notranslate"><span class="pre">synaptic</span></code> install <code class="docutils literal notranslate"><span class="pre">python-setuptools</span></code>, <code class="docutils literal notranslate"><span class="pre">python-scipy</span></code>, <code class="docutils literal notranslate"><span class="pre">python-matplotlib</span></code> and <code class="docutils literal notranslate"><span class="pre">python-tables</span></code> from the distribution packages</p>
</li>
<li><p class="first">Get a copy of <code class="docutils literal notranslate"><span class="pre">python-microscopy</span></code> by cloning from the repository:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hg</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">code</span><span class="o">.</span><span class="n">google</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">p</span><span class="o">/</span><span class="n">python</span><span class="o">-</span><span class="n">microscopy</span><span class="o">/</span>
</pre></div>
</div>
</li>
<li><p class="first">Install Django from the distribution package archive - ie <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">install</span> <span class="pre">python-django</span></code></p>
</li>
<li><p class="first">Make a new mysql user called <code class="docutils literal notranslate"><span class="pre">sample_db</span></code> with password <code class="docutils literal notranslate"><span class="pre">PYMEUSER</span></code> (can be modified in <code class="docutils literal notranslate"><span class="pre">SampleDB2/settings.py</span></code>).</p>
</li>
<li><p class="first">Create a new mysql database called <code class="docutils literal notranslate"><span class="pre">sample_db</span></code> and grant the <code class="docutils literal notranslate"><span class="pre">sample_db</span></code> user all rights. <a class="footnote-reference" href="#id4" id="id2">[2]</a></p>
</li>
<li><p class="first">Open a terminal window and change to the <code class="docutils literal notranslate"><span class="pre">PYME/SampleDB2/</span></code> directory.</p>
</li>
<li><p class="first">Test the installation so far by entering:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</span> <span class="n">sql</span> <span class="n">samples</span>
</pre></div>
</div>
<p>This should show the SQL which will be used to make the tables that <cite>SampleDB</cite> needs, and will only work if Django is installed and can connect to the database. If this fails, chase up the error messages.</p>
</li>
<li><p class="first">Create the tables by entering:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</span> <span class="n">syncdb</span>
</pre></div>
</div>
<p>This will create all the database tables and prompt you for an admin username and password.</p>
</li>
<li><p class="first">Test the setup by running the development server:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">runserver</span>
</pre></div>
</div>
<p>Now direct your browser to <code class="docutils literal notranslate"><span class="pre">localhost:8080</span></code> and you should get your first glimpse of the sample database. This will, however, only be visible on the local computer.</p>
</li>
</ol>
<p>Usernames, database names, and passwords can be customized for your site in <code class="docutils literal notranslate"><span class="pre">SampleDB2/settings.py</span></code> - for more details see the Django documentation.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">These instructions follow my re-installation on Ubuntu 14.04 LTS, which ships with Django 1.6. Other versions of Django might not work.</p>
</div>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>phpmyadmin can be substituted for your mysql admin interface of choice</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id4" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>steps 2&3 can be combined in phpmyadmin by checking a box during the user creation process</td></tr>
</tbody>
</table>
</div>
<div class="section" id="part-ii-getting-apache-to-serve-the-sampledb">
<h3>Part II - Getting Apache to serve the SampleDB<a class="headerlink" href="#part-ii-getting-apache-to-serve-the-sampledb" title="Permalink to this headline">¶</a></h3>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">In its default state, the PYME SampleDB is not secure. Only use behind a firewall and do so at your own risk/discretion. The version of the Django <code class="docutils literal notranslate"><span class="pre">settings.py</span></code> in the python-microscopy repository has <code class="docutils literal notranslate"><span class="pre">DEBUG</span></code> set to <code class="docutils literal notranslate"><span class="pre">True</span></code>, which is a known security risk. In a controlled environment, this risk is probably acceptable in return for easier troubleshooting, but you have been warned!</p>
</div>
<ol class="arabic">
<li><p class="first">Create a directory <code class="docutils literal notranslate"><span class="pre">/var/www/SampleDB/static</span></code> for the static files (if you want to host the files from another directory, you will need to change <code class="docutils literal notranslate"><span class="pre">STATIC_ROOT</span></code> in <code class="docutils literal notranslate"><span class="pre">settings.py</span></code> and the apache .conf file detailed in step 3).</p>
</li>
<li><p class="first">Install the static files by calling:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</span> <span class="n">collectstatic</span>
</pre></div>
</div>
</li>
<li><p class="first">Create a new file in <code class="docutils literal notranslate"><span class="pre">/etc/apache2/conf-available</span></code> called <code class="docutils literal notranslate"><span class="pre">SampleDB.conf</span></code> with the following contents (alter the paths to reflect where you have extracted python-microscopy):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">WSGIScriptAlias</span> <span class="o">/</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">david</span><span class="o">/</span><span class="n">python</span><span class="o">-</span><span class="n">microscopy</span><span class="o">/</span><span class="n">PYME</span><span class="o">/</span><span class="n">SampleDB2</span><span class="o">/</span><span class="n">SampleDB2</span><span class="o">/</span><span class="n">wsgi</span><span class="o">.</span><span class="n">py</span>
<span class="n">WSGIPythonPath</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">david</span><span class="o">/</span><span class="n">python</span><span class="o">-</span><span class="n">microscopy</span><span class="o">/</span><span class="n">PYME</span><span class="o">/</span><span class="n">SampleDB2</span><span class="o">/</span>
<span class="o"><</span><span class="n">Directory</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">david</span><span class="o">/</span><span class="n">python</span><span class="o">-</span><span class="n">microscopy</span><span class="o">/</span><span class="n">PYME</span><span class="o">/</span><span class="n">SampleDB2</span><span class="o">/</span><span class="n">SampleDB2</span><span class="o">/></span>
<span class="o"><</span><span class="n">Files</span> <span class="n">wsgi</span><span class="o">.</span><span class="n">py</span><span class="o">></span>
<span class="n">Require</span> <span class="nb">all</span> <span class="n">granted</span>
<span class="o"></</span><span class="n">Files</span><span class="o">></span>
<span class="o"></</span><span class="n">Directory</span><span class="o">></span>
<span class="n">Alias</span> <span class="o">/</span><span class="n">media</span><span class="o">/</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">www</span><span class="o">/</span><span class="n">SampleDB</span><span class="o">/</span><span class="n">static</span><span class="o">/</span>
<span class="o"><</span><span class="n">Directory</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">www</span><span class="o">/</span><span class="n">SampleDB</span><span class="o">/</span><span class="n">static</span><span class="o">/></span>
<span class="n">Order</span> <span class="n">deny</span><span class="p">,</span><span class="n">allow</span>
<span class="n">Allow</span> <span class="kn">from</span> <span class="nn">all</span>
<span class="o"></</span><span class="n">Directory</span><span class="o">></span>
</pre></div>
</div>
</li>
<li><p class="first">Activate the newly created <code class="docutils literal notranslate"><span class="pre">SampleDB.conf</span></code> by calling:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">a2enconf</span> <span class="n">SampleDB</span>
<span class="n">sudo</span> <span class="n">service</span> <span class="n">apache2</span> <span class="n">reload</span>
</pre></div>
</div>
</li>
<li><p class="first">Verify that you can now see the server from another machine.</p>
</li>
<li><p class="first"><strong>[Optional but reccomended]</strong> Lock the server down. Edit <code class="docutils literal notranslate"><span class="pre">settings.py</span></code> to add your machine name to <code class="docutils literal notranslate"><span class="pre">ALLOWED_HOSTS</span></code> and then set <code class="docutils literal notranslate"><span class="pre">DEBUG</span></code> to <code class="docutils literal notranslate"><span class="pre">False</span></code>. Restart apache with <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">service</span> <span class="pre">apache2</span> <span class="pre">reload</span></code> to make the changes take effect.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This alone is not enough to make SampleDB secure. You would also want to look at changing the database passwords and the <code class="docutils literal notranslate"><span class="pre">SECRET_KEY</span></code> in <code class="docutils literal notranslate"><span class="pre">settings.py</span></code>, as well as potentially restricting access to MySQL to the local machine. Some items are stored in the database as pickles, which means that, although difficult to exploit, a database breach theoretically has the capablilty to allow remote code execution.</p>
</div>
</li>
</ol>
</div>
<div class="section" id="part-iii-letting-other-machines-know-where-to-find-the-sampledb">
<h3>Part III - Letting other machines know where to find the SampleDB<a class="headerlink" href="#part-iii-letting-other-machines-know-where-to-find-the-sampledb" title="Permalink to this headline">¶</a></h3>
<p>Letting other machines find the sample database is as simple as setting an environment variable: <code class="docutils literal notranslate"><span class="pre">PYME_DATABASE_HOST</span></code> to the hostname or IP address of the server.</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="api/PYME.html" class="btn btn-neutral float-right" title="PYME package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="tiff_handling.html" class="btn btn-neutral float-left" title="TIFF support in PYME" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2016, David Baddeley
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>