To be able to run the app locally, change the datasets, or deploy a new version of the app, you need to do this setup first
Prerequisities: Git, pip and python (3.7.3 or newer) installed. GCP privileges for relevant parts of the project.
-
Ensure you have the updated repository version
-
If you don't have the repository locally, clone it from GitHub:
git clone https://github.com/ML-Bioinfo-CEITEC/genome_browser.git
-
otherwise, update the repository
git pull
-
-
Enter the api folder
cd api/
-
install packages
pip install -r requirements.txt
-
Go to GCP website and download secrets.py file from genome-browser-secrets-bucket.
-
Put the
secrets.py
file to theapi/db
folder -
Run
db/yaml_gen.py
script (for example in console withpython db/yaml_gen.py
command) -
Whitelist your IP in public IP section of the SQL database (Needed only for local running and new dataset upload)
- go to database connections tab
- click on add network and add your ipv4 adress to the list
- click Save
Prerequisities: you have completed the setting up part
- go to
db/config.py
and change thedeploy_mode
variable toFalse
- from the
api
folder, run the commandpython main.py
- the app is now running on your local URL (printed to console) connected to GCP SQL database
- [Optional] If you want to change the database connection to a local database, change the POSTGRES dictionary values in secrets.py (
public host
variable would belocalhost
) - [Optional] Change the
app.config['DEBUG']
toTrue
inmain.py
to see debug messages when developing the app
Prerequisities: you have completed the setting up part
- Ensure your data is in csv format with columns ordered like this:
-
Genes:
id,symbol,biotype,chr,start,end,strand
-
Binding sites:
protein_name,chr,start,end,strand,score,note
-
Proteins:
protein_name,protein_id,uniprot_url
- Put the three CSV files into the
api/db/csv_files
directory - go to
import_preparation.py
script and put the csv names to relevant variables - run the
import_preparation.py
script. The new, preprocessed csv files will be inapi/db/csv_files/prepared
folder. This step will delete all rows in the database, so the user will see no results until you complete the following steps. - go to genome-browser-bucket and upload the prepared files there
- go to the database page and click import
- For each separate prepared csv file do the following
- select the
genome-browser-bucket
and select the prepared csv file - verify the csv format is chosen
- select the
genome_data_db
database - type in the table name (
genes
,binding_sites
orproteins
), depending on the chosen file - click import
- wait until the file is transformed into table and click the import button at the top again
- select the
- After all the csv files are put into database, run the
import_finish.py
, creating the final table - [Optional] - delete the csv files from
genome-browser-bucket
Prerequisities: you have completed the setting up part
- install google cloud sdk if it's not already installed.
- Check the run 'gcloud init' checkbox at the end.
- Select the spring-ranger-289710 project in the console when
gcloud init
is executed. - Configure the default Compute Region and Zone to
europe-west3-a
region
- In the Google cloud sdk shell, ensure you're in the
api
folder of the project - Ensure the
deploy_mode
variable indb/config.py
is set toTrue
- run
gcloud app deploy
command (this will upload all local files from the api folder to GCP, including unstaged files) - confirm the deployment with
Y
command on prompt - [Optional] Delete the old version from the app engine page
The app engine server's configuration is specified in the app.yaml
file, generated from the data in secrets.py
.
If you want to deploy the app with new configuration, change the app.yaml
file according to the official docs.
If you want to change the database connection, change the POSTGRES
variable in secrets.py
If you want these new configurations to be the new default, upload the new secrets.py
to the genome-browser-secrets-bucket and notify other team members to update their local secrets.py
files and then regenerate app.yaml file with yaml_gen.py
script.
This is the root file of the application, running it will launch a server listening for HTTP requests.
This is the file containing the API logic. Currently, there are two endpoints
'/' endpoint returns the rendered HTML file with the paginated results based on the parameters in the request
'/download' endpoint returns the CSV file with filtered data based on the parameters in the request
This folder contains all the HTML templates that are rendered, using jinja2 syntax.
This file contains all the secrets of the app, do not share this file in any public way. If you want to update the secrets.py file, upload the new version to the genome-browser-secrets-bucket
on GCP.
This file contains all the required packages for the app. If you update the app with new dependencies, update this file and push it to github. Updating the file can be done with the command pip freeze > requirements.txt
in the api
folder
This file contains specific text areas of the website, which can be directly modified.
yaml_gen
, import_preparation
and import_finish
are helper scripts used for deployment and database updating. Their use is described in the relevant tutorials.