README.md 6.32 KB
Newer Older
Zhi Zhang's avatar
Zhi Zhang committed
1
# BSA4Yeast
Zhi Zhang's avatar
Zhi Zhang committed
2

Zhi Zhang's avatar
Zhi Zhang committed
3
BSA4Yeast is a comprehensive web application that performs QTL (Quantitative Trait Loci) mapping using bulk segregant analysis (BSA) of yeast sequencing data. It has the following main advantages and features: 
Zhi Zhang's avatar
Zhi Zhang committed
4

Zhi Zhang's avatar
Zhi Zhang committed
5
6
7
8
9
- fully automated
- multiple input file types
- private storage space
- comprehensive annotations
- web-based exploration
Zhi Zhang's avatar
Zhi Zhang committed
10

Zhi Zhang's avatar
Zhi Zhang committed
11
## Website of BSA4Yeast
Zhi Zhang's avatar
Zhi Zhang committed
12
13
[https://bsa4yeast.lcsb.uni.lu](https://bsa4yeast.lcsb.uni.lu)

Zhi Zhang's avatar
Zhi Zhang committed
14
15
16
17
18
19
20
21
## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

### Prerequisites

What things you need to install the software and how to install them

Zhi Zhang's avatar
Zhi Zhang committed
22
#### Virtual machine info
Zhi Zhang's avatar
Zhi Zhang committed
23
```
Zhi Zhang's avatar
Zhi Zhang committed
24
25
26
27
28
29
- os: CentOS 7.2
- memory: 16GB
- cores: 8
- user: bsa4yeast
- python app: /home/bsa4yeast/bsa4yeast
- python version: 2.7
Zhi Zhang's avatar
Zhi Zhang committed
30
31
32
33
34
35
36
```

### Installing

A step by step series of examples that tell you how to get a development env running

```
Zhi Zhang's avatar
Zhi Zhang committed
37
38
39
40
41
sudo yum update
sudo yum install redis python-devel tkinter
sudo yum group install "Development Tools"
sudo systemctl start redis
sudo systemctl enable redis
Zhi Zhang's avatar
Zhi Zhang committed
42

Zhi Zhang's avatar
Zhi Zhang committed
43
sudo easy_install pip
Zhi Zhang's avatar
Zhi Zhang committed
44

Zhi Zhang's avatar
Zhi Zhang committed
45
46
47
48
49
50
51
sudo adduser bsa4yeast
sudo su - bsa4yeast
git clone ssh://git@git-r3lab-server.uni.lu:8022/zhi.zhang/bsa4yeast.git
exit
sudo pip install -r /home/bsa4yeast/bsa4yeast/requirements.txt

sudo pip install gunicorn
Zhi Zhang's avatar
Zhi Zhang committed
52

Zhi Zhang's avatar
Zhi Zhang committed
53
54
sudo yum install nginx
```
Zhi Zhang's avatar
Zhi Zhang committed
55

Zhi Zhang's avatar
Zhi Zhang committed
56
### Deployment
Zhi Zhang's avatar
Zhi Zhang committed
57

Zhi Zhang's avatar
Zhi Zhang committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#### Gunicorn

1) Create the file ```/etc/systemd/system/gunicorn.service``` with the following content:

```
[Unit]
Description=gunicorn daemon
After=network.target

[Service]
PIDFile=/run/gunicorn/pid
User=bsa4yeast
Group=bsa4yeast
WorkingDirectory=/home/bsa4yeast/bsa4yeast
ExecStart=/usr/bin/gunicorn --limit-request-line 0 --access-logfile /home/bsa4yeast/log/gunicorn_access.log --error-logfile /home/bsa4yeast/log/gunicorn_error.log --log-level debug --workers 2 --bind unix:/home/bsa4yeast/bsa4yeast/bsa4yeast.sock manage:app
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM  $MAINPID

[Install]
WantedBy=multi-user.target
```
Zhi Zhang's avatar
Zhi Zhang committed
79
#### User
Zhi Zhang's avatar
Zhi Zhang committed
80
81
82

application is installed under bsa4yeast user
use `sudo su - bsa4yeast` to change user
Zhi Zhang's avatar
Zhi Zhang committed
83
84


Zhi Zhang's avatar
Zhi Zhang committed
85
86
87
88

#### Web server

1) Create the file ```/etc/nginx/conf.d/bsa4yeast.conf``` with the following content:
Zhi Zhang's avatar
Zhi Zhang committed
89
90

```
Zhi Zhang's avatar
Zhi Zhang committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;

server {
    listen 80;
    client_max_body_size    3000m;
    server_name bsa4yeast.uni.lu;

    location /static {
        alias /home/bsa4yeast/bsa4yeast/app/static;
        autoindex on;
    }

   
    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://unix:/home/bsa4yeast/bsa4yeast/bsa4yeast.sock;
    }
}
Zhi Zhang's avatar
Zhi Zhang committed
115
116
117
```


Zhi Zhang's avatar
Zhi Zhang committed
118
119
120
121
122
123
2) Edit the file /etc/nginx/nginx.conf:

Comment out the block server {} in /etc/nginx/nginx.conf
Change the user running nginx from nginx to bsa4yeast

3) Restart nginx
Zhi Zhang's avatar
Zhi Zhang committed
124
125

```
Zhi Zhang's avatar
Zhi Zhang committed
126
sudo systemctl restart nginx
Zhi Zhang's avatar
Zhi Zhang committed
127
128
```

Zhi Zhang's avatar
Zhi Zhang committed
129
#### Celery Worker
Zhi Zhang's avatar
Zhi Zhang committed
130

Zhi Zhang's avatar
Zhi Zhang committed
131
132
133
134
```
sudo yum install supervisor
```
Create the file /etc/supervisord.d/workers.ini with the following content:
Zhi Zhang's avatar
Zhi Zhang committed
135

Zhi Zhang's avatar
Zhi Zhang committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
```
[program:worker]
command=/bin/celery -A celery_worker.celery worker --workdir=/home/bsa4yeast/bsa4yeast/ --concurrency=4 --loglevel=debug -n %%h-parse
stdout_logfile=/home/bsa4yeast/log/celery_worker.log
stderr_logfile=/home/bsa4yeast/log/celery_worker.log
stdout_logfile_backups=5
stdout_logfile_maxbytes=10MB
stderr_logfile_backups=5
stderr_logfile_maxbytes=10MB
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=3600
killasgroup=true
user=bsa4yeast
```
#### Operation Manual
Zhi Zhang's avatar
Zhi Zhang committed
153

Zhi Zhang's avatar
Zhi Zhang committed
154
If web application python code is modified, gunicorn should be restarted:
Zhi Zhang's avatar
Zhi Zhang committed
155

Zhi Zhang's avatar
Zhi Zhang committed
156
157
158
```
sudo systemctl restart gunicorn
```
Zhi Zhang's avatar
Zhi Zhang committed
159

Zhi Zhang's avatar
Zhi Zhang committed
160
If celery worker python code is modified, restart the worker with:
Zhi Zhang's avatar
Zhi Zhang committed
161

Zhi Zhang's avatar
Zhi Zhang committed
162
163
164
```
sudo supervisorctl restart worker
```
Zhi Zhang's avatar
Zhi Zhang committed
165

Zhi Zhang's avatar
Zhi Zhang committed
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
#### config.py in bsa4yeast
```
import os
basedir = os.path.abspath(os.path.dirname(__file__))

class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
    WTF_CSRF_ENABLED = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    SQLALCHEMY_TRACK_MODIFICATIONS= True
    MAIL_SERVER = 'localhost'
    MAIL_PORT = 25
#    MAIL_USE_TLS = True
    MAIL_USERNAME = 'root'
    MAIL_PASSWORD = ''
    FLASKY_MAIL_SUBJECT_PREFIX = '[BSA4Yeast]'
    FLASKY_MAIL_SENDER = 'BSA4Yeast Admin <Admin@BSA4Yeast.com>'
    UPLOADS_FOLDER = os.path.join(basedir, 'app/uploads')
    RESULTS_FOLDER = os.path.join(basedir, 'app/results')
    UPLOADS_ANONY_FOLDER = os.path.join(basedir, 'app/uploads_anony')
    RESULTS_ANONY_FOLDER = os.path.join(basedir, 'app/results_anony')
    GENOMES_FOLDER = os.path.join(basedir, 'app/genomes')
    ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
    FLASKY_ADMIN = os.environ.get('FLASKY_ADMIN')
    CELERY_BROKER_URL = 'redis://localhost:6379/1'
    CELERY_RESULT_BACKEND = 'redis://localhost:6379/2'
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_IMPORTS=("app.tasks.mytask")
    DROPZONE_MAX_FILE_SIZE=3000
    DROPZONE_ALLOWED_FILE_CUSTOM=True
    DROPZONE_ALLOWED_FILE_TYPE='.fastq,.map,.bam'
    CUSTOM_UPLOADS_FOLDER_SIZE_LIMIT=8000000000
    CUSTOM_RESULTS_FOLDER_SIZE_LIMIT=4000000000
    DROPZONE_REDIRECT_VIEW='auth.upload'

    @staticmethod
    def init_app(app):
        pass

class DevelopmentConfig(Config):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')

class TestingConfig(Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data-test.sqlite')

class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data.sqlite')

config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
```
Zhi Zhang's avatar
Zhi Zhang committed
226
227
228

## Authors

Zhi Zhang's avatar
Zhi Zhang committed
229
230
231
****
|Author|Zhi Zhang|
|---|---
Zhi Zhang's avatar
Zhi Zhang committed
232
|E-mail|[zhi.zhang@uni.lu](mailto:zhi.zhang@uni.lu)
Zhi Zhang's avatar
Zhi Zhang committed
233

Zhi Zhang's avatar
Zhi Zhang committed
234
****
Zhi Zhang's avatar
Zhi Zhang committed
235
236
237

## License

Zhi Zhang's avatar
Zhi Zhang committed
238
This project is licensed under the GNU GPL License - see the [LICENSE](LICENSE) file for details
Zhi Zhang's avatar
Zhi Zhang committed
239
240
241

## Acknowledgments

Zhi Zhang's avatar
Zhi Zhang committed
242
243
* [Valentin Groues](https://wwwen.uni.lu/lcsb/people/valentin_groues)

Zhi Zhang's avatar
Zhi Zhang committed
244