-
Clone the git repo.
https://github.com/mukamel-lab-team/scmdb_py_dev.git; cd scmdb_py_dev
-
Set up virtual environment. Note that scmdb_py currently works with python3.5
virtualenv venv -p python3.5
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
deactivate
-
Create directory with proper permissions for user-login.sqlite.
mkdir scmdb_py/tmp
chmod 777 scmdb_py/tmp
- Find and move user-login.sqlite file to scmdb_py/tmp and change permissions to read+write+execute on all.
-
Set up default_config.py.
- Leave
APPLICATION_ROOT
blank - Make sure to not push default_config.py to github unless you have removed
all sensitive information!
- Leave
-
If the machine you are running this on does NOT have mysql installed, uncomment the lines
import pymsysql
andpymysql.install_as_MySQLdb()
in _init_.py. -
Run.
bash run_dev.sh
May need to change ports
-
On your web browser, go to
localhost:<port>
-
If running from a remote host (ie Banjo, Brainome), you must create an ssh tunnel
from your local machine.ssh -NfL localhost:<port>:localhost:<port> <user_name>@<server_name>
- Follow steps 1-5 of development setup.
- Move whole directory to
/var/www/
cd ..
sudo mv scmdb_py_dev /var/www/scmdb_py
- Set
APPLICATION_ROOT
in default_config.py.- This sets the url root for the portal.
- ex. To host the portal on website.com/portal, set
APPLICATION_ROOT='/portal'
.
- Edit .wsgi file to point to proper file paths.
- Edit .conf file in
/etc/apache2/sites-enabled
to point to proper file paths- 000-default.conf (http configuration) and default-ssl.conf (https configuration)
- Make sure you have no syntax errors in the apache2 conf.
apachectl configtest
- Make sure the proper version of mod_wsgi is installed (must be python3)
ldd /usr/lib/apache2/modules/mod_wsgi.so
- If not installed or compiled with the wrong version of python, first remove the old package using apt,
then installsudo apt install libapache2-mod-wsgi-py3
- Restart apache2
sudo service apache2 restart
- Read the error log
sudo less /var/log/apache2/brainome-error_log
- Double check permissions for the /static and /tmp directory.
- Make sure you did steps 3-6 of deployment setup.
- mod_wsgi only works if it has been compiled with the same version of python as the virtualenv.
- Check if default_config.py is properly setup.
scmdb_py_dev/
|-- scmdb_py.wsgi *WSGI script file for hosting via apache *Don't Touch*
|-- requirements.txt *list of required python packages
|-- run_dev.sh
|-- scmdb_py/
| |-- __init__.py *Application factory (setup)
| |-- frontend.py *responsible for all views (handles URL requests)
| |-- content.py *all server side data querying and plot generation
| |-- assets.py *gathers all javascript files in assets directory
| |-- default_config.py *Configuration file for Flask. (info for MySQL, email, etc.)
| |-- assets/ *All your .js and .css files go here
| | |-- scripts/ *Individual javascript files
| | | |-- app.js
| | | |-- customview.js *Frontend functions for data browser (plotting, sending queries)
| | | |-- request_new_ensemble.js *Frontend functions for request new ensemble page
| | | |-- tabular_dataset_rs1.js *Frontend functions for summary (metadata) pages
| | | |-- tabular_dataset_rs2.js
| | | |-- tabular_ensemble.js
| | | |-- vendor/ *All downloaded javascript libraries
| | | | |-- ...
| | |-- styles/ *Individual css files
| | | |-- app_base.css *Style for navigation bar.
| | | |-- browser.css *Style for data browser
| | | |-- vendor/ *All downloaded css files
| | | | |-- ...
| |-- templates/ *HTML files
| | |-- base.html *Base template file for ensembleview.html
| | |-- ensembleview.html *Main HTML file for data browser page of portal
| | |-- request_new_ensemble.html
| | |-- tabular_dataset_rs1.html
| | |-- tabular_dataset_rs2.html
| | |-- tabular_ensemble.html
| | |-- accounts/ *HTML files for account/login pages
| | |-- components/ *Individual componenents of ensembleview.html
| | | |-- search_options.html *Gene methylation search box
| | | |-- mch_box.html *Methylation box plot / heatmap
| | | |-- mch_correlated_genes.html *Methylation box plot / heatmap
| | | |-- mch_scatter.html *Methylation cluster plot
| | |-- partials/ *HTML code to be included in all pages
| | | |-- _flashes.html *flash message settings
| | | |-- _head.html *included in <head> of all pages
| | |-- macros/ *Macros (functions) used by jinja to generate HTML
| | | |-- nav_macros.html *Edit this to change navigation bar items
| |-- static/ *All static files (.js files generated by Flask, images) *Don't Touch*
| |-- tmp/
| | |-- user-login.sqlite *User login information. DON'T PUSH TO GITHUB
- User clicks a button on page. (ie. Search for the gene Sox6)
- Javascript event handler detects an event and runs the appropriate function that
sends an AJAX request via HTML GET or POST method. - frontend.py handles the GET/POST method and runs a function from content.py.
- content.py queries MySQL, shapes the data using pandas and numpy, generates
HTML for plots, and returns data as a list or dict to frontend.py. - frontend.py sends the data back to the client in JSON format.
- Javascript updates what the user sees on screen.