Commit 5ffda6b7 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

Merge branch 'master' into 'release'

Prepare for v1.1.0

See merge request !29
parents 321c8931 da0501a0
Pipeline #47794 canceled with stages
in 25 seconds
......@@ -99,7 +99,7 @@ deploy-webserver-targetcentric:
- cd ansible
- whoami
- ansible-playbook -vvv -i ./hosts_master deploy.yaml
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_targetcentric galaxy_base_url=$GALAXY_BASE_URL_targetcentric galaxy_apikey=$GALAXY_APIKEY_targetcentric galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_targetcentric secret_key=$SECRET_KEY_targetcentric dbname=$DBNAME_targetcentric dbuser=$DBUSER_targetcentric dbpassword=$DBPASSWORD_targetcentric dbhost=$DBHOST_targetcentric dbport=$DBPORT_targetcentric http_port=$HTTP_PORT_targetcentric branch=targetcentric"
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_targetcentric galaxy_base_url=$GALAXY_BASE_URL_targetcentric galaxy_apikey=$GALAXY_APIKEY_targetcentric galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_targetcentric secret_key=$SECRET_KEY_targetcentric dbname=$DBNAME_targetcentric dbuser=$DBUSER_targetcentric dbpassword=$DBPASSWORD_targetcentric dbhost=$DBHOST_targetcentric dbport=$DBPORT_targetcentric http_port=$HTTP_PORT_targetcentric branch=$CI_COMMIT_REF_NAME gacode=$GACODE_targetcentric ippidb_media=$IPPIDB_MEDIA_targetcentric"
only:
- targetcentric
......@@ -122,7 +122,7 @@ deploy-webserver-test:
- cd ansible
- whoami
- ansible-playbook -vvv -i ./hosts_master deploy.yaml
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_master galaxy_base_url=$GALAXY_BASE_URL_master galaxy_apikey=$GALAXY_APIKEY_master galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_master secret_key=$SECRET_KEY_master dbname=$DBNAME_master dbuser=$DBUSER_master dbpassword=$DBPASSWORD_master dbhost=$DBHOST_master dbport=$DBPORT_master http_port=$HTTP_PORT_master branch=$CI_COMMIT_REF_NAME gacode=$GACODE_master"
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_master galaxy_base_url=$GALAXY_BASE_URL_master galaxy_apikey=$GALAXY_APIKEY_master galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_master secret_key=$SECRET_KEY_master dbname=$DBNAME_master dbuser=$DBUSER_master dbpassword=$DBPASSWORD_master dbhost=$DBHOST_master dbport=$DBPORT_master http_port=$HTTP_PORT_master branch=$CI_COMMIT_REF_NAME gacode=$GACODE_master ippidb_media=$IPPIDB_MEDIA_master"
only:
- master
......@@ -145,6 +145,6 @@ deploy-webserver-production:
- cd ansible
- whoami
- ansible-playbook -vvv -i ./hosts_release deploy.yaml
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_release galaxy_base_url=$GALAXY_BASE_URL_release galaxy_apikey=$GALAXY_APIKEY_release galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_release secret_key=$SECRET_KEY_release dbname=$DBNAME_release dbuser=$DBUSER_release dbpassword=$DBPASSWORD_release dbhost=$DBHOST_release dbport=$DBPORT_release http_port=$HTTP_PORT_release branch=$CI_COMMIT_REF_NAME gacode=$GACODE_release"
--extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_release galaxy_base_url=$GALAXY_BASE_URL_release galaxy_apikey=$GALAXY_APIKEY_release galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_release secret_key=$SECRET_KEY_release dbname=$DBNAME_release dbuser=$DBUSER_release dbpassword=$DBPASSWORD_release dbhost=$DBHOST_release dbport=$DBPORT_release http_port=$HTTP_PORT_release branch=$CI_COMMIT_REF_NAME gacode=$GACODE_release ippidb_media=$IPPIDB_MEDIA_release"
only:
- release
......@@ -231,6 +231,12 @@
GA_CODE = "{{ gacode }}"
marker: "# {mark} ANSIBLE MANAGED GOOGLE ANALYTICS ID"
when: gacode is defined
- name: Add media_url setting to iPPI-DB settings
blockinfile:
path: "{{ checkout_path }}/ippisite/ippisite/{{ ansible_hostname }}_settings.py"
block: |
MEDIA_URL = "{{ ippidb_media }}"
marker: "# {mark} ANSIBLE MEDIA_URL SETTINGS"
- name: Add email/debug settings to iPPI-DB settings
blockinfile:
path: "{{ checkout_path }}/ippisite/ippisite/{{ ansible_hostname }}_settings.py"
......@@ -326,6 +332,10 @@
lineinfile: dest="{{ service_conf_path }}/httpd.conf"
insertbefore=BOF
line="LimitRequestLine 32000"
- name: add httpd conf to set larger POST requests body
lineinfile: dest="{{ service_conf_path }}/httpd.conf"
regex='^LimitRequestBody'
line="LimitRequestBody 104857600"
- name: copy systemd service file for IPPIDB-web
template:
src: "ippidb-web.service"
......@@ -339,13 +349,21 @@
become: true
- name: Enable firewalld
service: name=firewalld state=started enabled=yes
- name: open http firewall port
- name: open http firewall service
firewalld:
service: http
zone: public
immediate: yes
permanent: true
state: enabled
- name: open http firewall port
firewalld:
port: "{{ http_port }}/tcp"
zone: public
permanent: true
immediate: yes
state: enabled
#
# Start web server
#
......
......@@ -52,6 +52,6 @@
become: true
- name: Open firwall to port 80 81 traffic
firewalld:
port: 80-81/tcp
port: "{{ http_port }}/tcp"
permanent: true
state: enabled
......@@ -19,24 +19,26 @@ import os
import sys
import matplotlib
# avoid using tkinter with matplotlib
matplotlib.use('agg')
matplotlib.use("agg")
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))
import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'ippisite.settings'
os.environ["DJANGO_SETTINGS_MODULE"] = "ippisite.settings"
django.setup()
# -- Project information -----------------------------------------------------
project = 'iPPI-DB'
copyright = '2018, Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio'
author = 'Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio'
project = "iPPI-DB"
copyright = "2018, Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio"
author = "Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio"
# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = ''
release = ""
# -- General configuration ---------------------------------------------------
......@@ -49,26 +51,26 @@ release = ''
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.graphviz',
'sphinxcontrib.bibtex'
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.graphviz",
"sphinxcontrib.bibtex",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -91,7 +93,7 @@ pygments_style = None
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
......@@ -103,7 +105,7 @@ html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
......@@ -119,7 +121,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'iPPI-DBdoc'
htmlhelp_basename = "iPPI-DBdoc"
# -- Options for LaTeX output ------------------------------------------------
......@@ -128,15 +130,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
......@@ -146,8 +145,13 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'iPPI-DB.tex', 'iPPI-DB Documentation',
'Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio', 'manual'),
(
master_doc,
"iPPI-DB.tex",
"iPPI-DB Documentation",
"Rachel Torchet, Alexandra Moine-Franel, Hélène Borges, Bryan Brancotte, Olivia Doppelt-Azeroual, Fabien Mareuil, Hervé Ménager, Olivier Sperandio",
"manual",
),
]
......@@ -155,10 +159,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'ippi-db', 'iPPI-DB Documentation',
[author], 1)
]
man_pages = [(master_doc, "ippi-db", "iPPI-DB Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
......@@ -167,9 +168,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'iPPI-DB', 'iPPI-DB Documentation',
author, 'iPPI-DB', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"iPPI-DB",
"iPPI-DB Documentation",
author,
"iPPI-DB",
"One line description of project.",
"Miscellaneous",
),
]
......@@ -188,7 +195,7 @@ epub_title = project
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]
# -- Extension configuration -------------------------------------------------
......@@ -196,16 +203,16 @@ epub_exclude_files = ['search.html']
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}
# -- Extension configuration -------------------------------------------------i
autoclass_content = "both" # include both class docstring and __init__
autodoc_default_flags = [
# Make sure that any autodoc declarations show the right members
"members",
"private-members",
"show-inheritance",
# Make sure that any autodoc declarations show the right members
"members",
"private-members",
"show-inheritance",
]
autosummary_generate = True # Make _autosummary files and include them
napoleon_numpy_docstring = False # Force consistency, leave only Google
......@@ -213,11 +220,11 @@ napoleon_use_rtype = False # More legible
# The suffix of source filenames.
autosummary_generate = True
exclude_patterns = ['_build']
exclude_patterns = ["_build"]
#do not try to import tkinter for sphinx
autodoc_mock_imports = ['_tkinter']
# do not try to import tkinter for sphinx
autodoc_mock_imports = ["_tkinter"]
bibtex_bibfiles = [
'refs.bib',
"refs.bib",
]
......@@ -28,7 +28,16 @@ from .models import (
Ppi,
ProteinDomainComplex,
Contribution,
Cavity,
Chain,
PDB,
Ligand,
InteractFile,
Partner,
Distance,
MetaInformation,
Job,
Network,
)
from .tasks import launch_validate_contributions
......@@ -62,6 +71,124 @@ class ViewOnSiteModelAdmin(admin.ModelAdmin):
)
@admin.register(Network)
class NetworkAdmin(admin.ModelAdmin):
list_display = ("label", "number", "jsonfile", "default")
search_fields = ("label",)
@admin.register(PDB)
class PDBAdmin(admin.ModelAdmin):
list_display = ("code", "chains_info")
search_fields = ("code",)
def chains_info(self, obj):
return "\t".join(
[
"{}: {}".format(chain.pdb_chain_id, chain.protein.uniprot_id)
for chain in obj.chain_set.all()
]
)
@admin.register(Chain)
class ChainAdmin(admin.ModelAdmin):
list_display = ("pdb_chain_id", "pdb_code", "protein")
search_fields = ("pdb_chain_id", "pdb__code", "protein__uniprot_id")
list_filter = ("pdb_chain_id", "protein__organism__name")
# if pdb is asked request never return
readonly_fields = ("pdb",)
def pdb_code(self, obj):
return obj.pdb.code
@admin.register(InteractFile)
class InteractFileAdmin(admin.ModelAdmin):
list_display = ("chain_info", "label")
list_filter = ("label",)
search_fields = ("chain__protein__uniprot_id",)
# if chain is asked request never return
readonly_fields = ("chain",)
def chain_info(self, obj):
return "{} {} {}".format(
obj.chain.pdb.code, obj.chain.pdb_chain_id, obj.chain.protein.uniprot_id
)
@admin.register(Ligand)
class LigandAdmin(admin.ModelAdmin):
list_display = (
"iupac_name",
"pdb_ligand_id",
"supplementary_id",
"pdb_code",
)
list_filter = ("pdb_ligand_id",)
search_fields = ("pdb_ligand_id", "supplementary_id", "pdb__code")
readonly_fields = ("pdb",)
def pdb_code(self, obj):
return obj.pdb.code
@admin.register(Partner)
class PartnerAdmin(admin.ModelAdmin):
list_display = ("partner",)
readonly_fields = ("chain", "ligand")
def partner(self, obj):
if obj.ligand:
return "Type: ligand, {}_{} {}".format(
obj.ligand.pdb_ligand_id,
obj.ligand.supplementary_id,
obj.ligand.pdb.code,
)
else:
return "Type: protein, {} {}".format(
obj.chain.protein.uniprot_id, obj.chain.pdb.code
)
@admin.register(Cavity)
class CavityAdmin(admin.ModelAdmin):
list_display = ("full_name", "info")
search_fields = ("full_name",)
list_filter = ("chain__protein__organism__name",)
readonly_fields = ("chain", "partner")
def info(self, obj):
if obj.partner.ligand:
return "Cavity {} from {} with {}_{} in {}".format(
obj.cavity_number,
obj.chain.protein.uniprot_id,
obj.partner.ligand.pdb_ligand_id,
obj.partner.ligand.supplementary_id,
obj.chain.pdb.code,
)
else:
return "Cavity {} from {} with {} in {}".format(
obj.cavity_number,
obj.chain.protein.uniprot_id,
obj.partner.chain.protein.uniprot_id,
obj.chain.pdb.code,
)
@admin.register(Distance)
class DistanceAdmin(admin.ModelAdmin):
list_display = ("similiarity_between", "distance")
def similiarity_between(self, obj):
return "{} and {}".format(obj.cavity1.full_name, obj.cavity2.full_name)
@admin.register(MetaInformation)
class MetaInformationAdmin(admin.ModelAdmin):
list_display = ("average", "std", "maximum", "minimum", "normalize_factor")
@admin.register(Job)
class JobModelAdmin(admin.ModelAdmin):
date_hierarchy = "task_result__date_done"
......
......@@ -551,7 +551,9 @@ TYPE_MOLECULE = (("smiles", "smiles"), ("iupac", "iupac"), ("sketch", "sketch"))
class CompoundForm(forms.Form):
compound_name = forms.CharField(
label=_("compound_name_label"), required=True, help_text=_(""),
label=_("compound_name_label"),
required=True,
help_text=_(""),
)
ligand_id = forms.CharField(
label=_("PDB Ligand ID"),
......@@ -805,7 +807,11 @@ class BaseInlineNestedFormSet(forms.BaseInlineFormSet):
class CompoundActivityResultForm(ModelForm):
compound_name = forms.ChoiceField(choices=(), required=True)
activity_mol = forms.DecimalField(
label="Activity", required=True, max_digits=15, decimal_places=10, min_value=0,
label="Activity",
required=True,
max_digits=15,
decimal_places=10,
min_value=0,
)
activity_unit = forms.CharField(
label="Activity unit",
......@@ -1014,7 +1020,8 @@ CompoundActivityResultInlineFormset = inlineformset_factory(
class TestActivityDescriptionForm(forms.ModelForm):
test_name = CharFieldDataList(
data_class=models.TestActivityDescription, data_attr="test_name",
data_class=models.TestActivityDescription,
data_attr="test_name",
)
cell_line_name = CharFieldDataList(
......@@ -1395,7 +1402,9 @@ class CompoundPKResultForm(ModelForm):
super().__init__(*args, **kwargs)
for f in self.fields.values():
f.widget.attrs.update({"class": "col-3"})
if isinstance(f, forms.BooleanField) and not isinstance(f.widget, forms.Select):
if isinstance(f, forms.BooleanField) and not isinstance(
f.widget, forms.Select
):
f.widget.attrs.update({"class": "col-3 mb-4"})
def has_changed(self):
......
from django.core.management.base import OutputWrapper
class TaskOutWrapper(OutputWrapper):
"""
OutWrapper with celery task object, allow to update
std_out and std_err in django database Job
"""
def __init__(
self, out, style_func=None, ending="\n", task=None, std_out=None, std_err=None
):
super(TaskOutWrapper, self).__init__(out, style_func=style_func, ending=ending)
self.task = task
self.std_out = std_out
self.std_err = std_err
def write(self, msg, style_func=None, ending=None):
super(TaskOutWrapper, self).write(msg, style_func=style_func, ending=ending)
if self.task:
if self.std_out:
self.task.write(std_out=msg, with_print=False)
else:
self.task.write(std_err=msg, with_print=False)
from django.core.management.base import AppCommand
from ippidb.models.targetcentric import (
Cavity,
Chain,
PDB,
Partner,
)
from ippidb.management.commands import TaskOutWrapper
from celery import states
import os
import sys
import pandas as pd
"""
Command to clean targetcentric databases from cavities to Protein
"""
def file_exist(string):
"""
Test if a file exist
"""
if os.path.exists(string):
return string
else:
raise FileNotFoundError(string)
class Command(AppCommand):
"""
Command to clean targetcentric databases from cavities to Protein
"""
help = "Load Cavities from global csv file and delete all Cavities not present in the csv"
def __init__(
self, stdout=None, stderr=None, no_color=False, force_color=False, task=None,
):
super(Command, self).__init__(
stdout=stdout, stderr=stderr, no_color=no_color, force_color=force_color
)
if task:
task.update_state(state=states.STARTED)
self.stdout = TaskOutWrapper(stdout or sys.stdout, task=task, std_out=True)
self.stderr = TaskOutWrapper(stderr or sys.stderr, task=task, std_err=True)
def add_arguments(self, parser):
parser.add_argument(
"-c", "--csv", type=file_exist, help="cavities descriptors file, csv format"
)
parser.add_argument(
"-d",
"--delete",
dest="delete",
action="store_true",
help="If not flagged only list cavities present in the database and not present in the csv file",
)
def handle(self, *args, **options):
"""
Perform the command's actions
"""
database_cavities = Cavity.objects.all()
delete = options["delete"]
current_cavities = []
csv = pd.read_csv(options["csv"], sep=",")
clean = 0
for index, row in csv.iterrows():
current_cavities.append(row["Cavity"])
for cavity in database_cavities:
if cavity.full_name not in current_cavities:
clean = 1
self.stdout.write(
self.style.WARNING(
"WARNING {} doesn't exist in csv file".format(cavity.full_name)
)
)
if delete:
cavity.delete()
if not clean:
self.stdout.write(self.style.SUCCESS("No Cavity to remove"))
chains = Chain.objects.filter(cavity=None, partner=None)
clean = 0
for chain in chains:
try:
partner = Partner.objects.get(chain=chain.id)
except Partner.DoesNotExist:
partner = None
if not chain.cavity_set.count() and not partner:
clean = 1
self.stdout.write(
self.style.WARNING(
"WARNING {} {} is not implicated in a cavity".format(
chain.pdb.code, chain.pdb_chain_id
)
)
)
if delete:
chain.delete()
if not clean:
self.stdout.write(self.style.SUCCESS("No Chain to remove"))
pdbs = PDB.objects.filter(chain=None)
clean = 0
for pdb in pdbs:
if not pdb.chain_set.count():
clean = 1
self.stdout.write(
self.style.WARNING(
"WARNING {} has no linked chain".format(pdb.code)
)
)
if delete: