From fbe1600c6202e17c7c536cd70a98079d3847e25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loraine=20Brillet-Gu=C3=A9guen?= Date: Mon, 5 Aug 2024 21:48:01 +0200 Subject: [PATCH] Handle blast predefined configurations (#34) Handle blast predefined configurations --- README.md | 3 ++- molecule/default/converge.yml | 2 +- molecule/default/verify.yml | 22 +++++++++++----------- templates/sequenceserver.conf.j2 | 19 ++++++++++++++++--- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8930e7c..3234a3c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ sequenceserver_blast_db: users: ['fbar','jsmith'] web_page_title: 'blablabla' placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}] + conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}] ``` This is the variable used to define the BLAST databases. @@ -55,7 +56,7 @@ Each database is defined as a dictionary of the following parameters: - `group` Optional. Useful if the database needs restricted access. An LDAP group ("gid"). LDAP users who are member of this group will have access to the database. - `web_page_title` Optional. The title displayed at the top of the web page. If not provided, the default title is "BLAST server for `name`". - `placeholders` Optional. A list of placeholder dictionaries `{key: 'key_item', value: 'value_item'}` that are used to customize top or bottom supplementary HTML code (see `sequenceserver_top_web_page_html_path` and `sequenceserver_bottom_web_page_html_path`). For example `placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}]`. -- `conf_options` Optional. A list of supplementary SequenceServer configuration options dictionaries `{key: 'key_item', value: 'value_item'}` (see [SequenceServer documentation](https://sequenceserver.com/doc/#basics)). For example `conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}]`. +- `conf_options` Optional. A list of supplementary SequenceServer configuration options as dictionaries `{key: 'key_item', value: 'value_item'}` (see [SequenceServer documentation](https://sequenceserver.com/doc/#basics)). For example `[{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}]` Unique `name` and `port` are mandatory for each database. `users`, `ldap_businesscategory` and `group` are optional and can be used to add an authentication layer with the nginx-auth-ldap module. Choose one single authentication mode for each database. diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 4e839ad..147ca92 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -12,7 +12,7 @@ port: '4567' path: '/tmp/test-data' placeholders: [{key: 'key_string', value: 'value1'}, {key: 'key_link', value: 'my favorite link'}] - conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}] + conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}] sequenceserver_top_web_page_html_path: "/tmp/top_web_page.html" sequenceserver_bottom_web_page_html_path: "/tmp/bottom_web_page.html" sequenceserver_home_url: "http://myfavoritewebsite.com" diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index ee5cb9a..7d8926d 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -26,6 +26,17 @@ - name: Display SequenceServer service logs debug: msg: "{{ log.content | b64decode }}" + - name: Get the SequenceServer configuration file of my_db + slurp: + src: "/etc/sequenceserver/config/sequenceserver.my_db.conf" + register: my_db_conf + - name: Display content of the SequenceServer configuration file of my_db + debug: + msg: "{{ my_db_conf.content | b64decode }}" + - name: Check that conf_option is in the SequenceServer configuration file of my_db + set_fact: + grep_slurm_batch: "{{ my_db_conf.content | b64decode | regex_findall('databases_widget') | first }}" + failed_when: grep_slurm_batch != 'databases_widget' - name: Test that SequenceServer service is running for my_db systemd: name: sequenceserver-my_db.service @@ -83,14 +94,3 @@ set_fact: grep_slurm_batch: "{{ lib_modified_for_hpc_integration.content | b64decode | regex_findall('slurm_sbatch.sh') | first }}" failed_when: grep_slurm_batch != 'slurm_sbatch.sh' - - name: Get the SequenceServer configuration file of my_db - slurp: - src: "/etc/sequenceserver/config/sequenceserver.my_db.conf" - register: my_db_conf - - name: Display content of the SequenceServer configuration file of my_db - debug: - msg: "{{ my_db_conf.content | b64decode }}" - - name: Check that conf_option is in the SequenceServer configuration file of my_db - set_fact: - grep_slurm_batch: "{{ my_db_conf.content | b64decode | regex_findall('databases_widget') | first }}" - failed_when: grep_slurm_batch != 'databases_widget' diff --git a/templates/sequenceserver.conf.j2 b/templates/sequenceserver.conf.j2 index 95b5336..5fdc9e8 100644 --- a/templates/sequenceserver.conf.j2 +++ b/templates/sequenceserver.conf.j2 @@ -1,9 +1,22 @@ :port: '{{ item.port }}' :database_dir: '{{ item.path }}' {% if item.conf_options is defined and item.conf_options %} -{% for option in item.conf_options %} -{% if option.key is defined and option.key and option.value is defined and option.value %} -:{{ option.key }}: '{{ option.value }}' +{% for conf_option in item.conf_options %} +{% if conf_option.key is defined and conf_option.key and conf_option.value is defined and conf_option.value %} +{% if conf_option.key != 'options' %} +:{{ conf_option.key }}: '{{ conf_option.value }}' +{% else %} +:options: +{% for blast_type, blast_configs in conf_option.value.items() %} + :{{ blast_type }}: +{% for blast_config, blast_params in blast_configs.items() %} + :{{ blast_config }}: +{% for blast_param in blast_params %} + - {{ blast_param }} +{% endfor %} +{% endfor %} +{% endfor %} +{% endif %} {% endif %} {% endfor %} {% endif %} \ No newline at end of file