diff --git a/.gitignore b/.gitignore index 0b050b158e8ceb244a4748d76d9a09de7ca0c826..ef3dcd80ec131990fd6a9ecbf4a2e387ec437bbe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ .env .env_dev .idea/ +.vscode # Backend static files backend/public diff --git a/README.md b/README.md index b30ddc99d8def6d7a432100930dd4bf53efec60a..0fc2c1b19192b1e6d057cf947c1e1ca608956613 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Therefore to run the application you need: #### Configuration +For `docker-compose`, you need to create a `.env` file: `touch .env`. + The settings of the Django server is based on the `backend/.env` file. You can copy the sample file (`cp backend/.env.sample backend/.env`) and fill in the variables. @@ -29,4 +31,29 @@ You can of course customize more of the Django server settings in the `settings` ### Run the application -#### Populate the database \ No newline at end of file +For the moment, only the `docker-compose.dev.yaml` is used. To run the application simply run the command: + +```bash +docker-compose -f docker-compose.dev.yaml up --build +``` + +The `--build` option is only necessary during the first usage or when you make changes that need the docker +container to be built again. + +Since directories with source codes are mounted in the containers, changes you make locally should be +directly reflected on the application. + +#### Populate the database + +You have a set of scripts available within the `backend/scripts` directory that you can execute directly +from within the container. First identify the container ID corresponding to the backend with `docker ps` command. Then you can execute a bash terminal within the container and execute the scripts you want: + +```bash +docker exec -it YOURCONTAINER_ID bash +root@YOURCONTAINER_ID:/code# python scripts/script.py +``` + +For the moment you can: + +* Import all kegg orthologies with `load_kegg.py`: It directly fetch all KEGGs KO from the KEGG REST API. +* Import genes from IGC catalog from the [annotation file](ftp://ftp.cngb.org/pub/SciRAID/Microbiome/humanGut_9.9M/GeneAnnotation/IGC.annotation_OF.summary.gz). You can a small part of this annotation file in the `dev_data` folder. diff --git a/dev_data/IGC_sample.annotation_OF.summary b/backend/dev_data/IGC_sample.annotation_OF.summary similarity index 100% rename from dev_data/IGC_sample.annotation_OF.summary rename to backend/dev_data/IGC_sample.annotation_OF.summary diff --git a/backend/requirements.txt b/backend/requirements.txt index 6100e13d6e68f09fbec770af30380e126a042bc7..deec47d7a3560554891974d73ce98f74330c344e 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,3 +1,5 @@ +certifi==2019.6.16 +chardet==3.0.4 Django==2.2.1 django-cors-headers==3.0.2 django-environ==0.4.5 @@ -5,10 +7,14 @@ django-extensions==2.1.7 django-filter==2.1.0 djangorestframework==3.9.4 djangorestframework-jwt==1.11.0 +idna==2.8 numpy==1.16.4 pandas==0.24.2 psycopg2==2.8.2 PyJWT==1.7.1 +python-dateutil==2.8.0 pytz==2019.1 +requests==2.22.0 six==1.12.0 -sqlparse==0.3.0 \ No newline at end of file +sqlparse==0.3.0 +urllib3==1.25.3 diff --git a/backend/scripts/load_kegg_ko.py b/backend/scripts/load_kegg_ko.py index c0b6952f1187eb98e1d11e01a740fe3d12509e4b..7222c285d48c3c95b4329bb8de0f05615305f855 100755 --- a/backend/scripts/load_kegg_ko.py +++ b/backend/scripts/load_kegg_ko.py @@ -37,7 +37,11 @@ def parse_ko(line): """ content = line.split('\t') function_id = content[0].split(':')[1] - names = content[1].split(';') + if ';' in content[1]: + names = content[1].split(';') + else: + _LOGGER.warning(f"Parsing issue with {function_id}, corresponding line: {line}") + names = [content[1], ''] # Ugly fix to handle one specific case with no name: K23479 if '[EC:' in names[1]: ec_number = names[1].split('[EC:')[1].rstrip(']') else: diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index e06183bd45bf27d66298035065e0b5fdb3721e1c..40ead5c03b73e8a0fc44624ced682970d6ec77a5 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -33,7 +33,7 @@ services: build: context: ./frontend volumes: - - ./frontend:/app:ro + - ./frontend:/app - '/app/node_modules' ports: - "8080:8080" diff --git a/frontend/src/components/Histogram.vue b/frontend/src/components/Histogram.vue index 1740393d4faa03e0cd52c13618a082510f3ea332..27e6d514e1390a29cb10ac366ac37db6ab3ef479 100644 --- a/frontend/src/components/Histogram.vue +++ b/frontend/src/components/Histogram.vue @@ -8,32 +8,32 @@ import Chart from 'chart.js'; export default { - props: { - geneLengthData: { - type: Object, - required: true - } - }, - updated() { - this.createChart('histogram'); - }, - methods: { + props: { + geneLengthData: { + type: Object, + required: true, + }, + }, + updated() { + this.createChart('histogram'); + }, + methods: { createChart(chartId) { const ctx = document.getElementById(chartId); const histoData = { - labels: this.geneLengthData.labels, - datasets:[ - { - label: 'Number of genes', - data: this.geneLengthData.counts - } - ] - } + labels: this.geneLengthData.labels, + datasets: [ + { + label: 'Number of genes', + data: this.geneLengthData.counts, + }, + ], + }; const myChart = new Chart(ctx, { type: 'bar', data: histoData, }); - } - } -} -</script> \ No newline at end of file + }, + }, +}; +</script>