diff --git a/ippisite/ippidb/templates/about-general.html b/ippisite/ippidb/templates/about-general.html new file mode 100644 index 0000000000000000000000000000000000000000..1877a5f811ffcc4abf15c69c51a268fa3cc41371 --- /dev/null +++ b/ippisite/ippidb/templates/about-general.html @@ -0,0 +1,18 @@ +{% extends "about.html" %} + +{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} + +{% block pagetitle %}GENERAL INFORMATION{% endblock%} + +{% block view_content %} +<ul> + <li>Number of compounds: {{ compounds_count }}</li> + <li>Total number of binding data: {{ car_count }}</li> + <li>Total number of biochemical binding data: {{ bioch_car_count }}</li> + <li>Total number of cellular binding data: {{ cell_car_count }}</li> + <li>Number of proteins: {{ proteins_count }}</li> + <li>Number of families: {{ families_count }}</li> + <li>Number of PPI targets: {{ ppis_count }}</li> + <li>Number of bibliographic sources: {{ biblio_count }}</li> +</ul> +{% endblock %} diff --git a/ippisite/ippidb/templates/about-pharmacology.html b/ippisite/ippidb/templates/about-pharmacology.html new file mode 100644 index 0000000000000000000000000000000000000000..a71166c69edd48411f02bdfeaed21bc8b531db6d --- /dev/null +++ b/ippisite/ippidb/templates/about-pharmacology.html @@ -0,0 +1,130 @@ +{% extends "about.html" %} + + +{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} + +{% block pagetitle %}PHARMACOLOGY{% endblock%} + +{% block view_content %} +<div class="row"> + <div class="card col-sm-12 col-md-6"> + <canvas id="pxc_by_test_type" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-6"> + <canvas id="bioch_tests_histo" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-6"> + <canvas id="data_per_ppi_family" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-6"> + <canvas id="cell_tests_histo" style="width:300px; height:200px;"></canvas> + </div> +</div> +<div class="row"> + <div class="card col-md-12"> + <canvas id="le_lle_biplot" style="width:300px; height:200px;"></canvas> + </div> +</div> + +<script> + + var biochTestData = { + labels: {{ biochemical_tests_count_by_name.labels|safe }}, + datasets: [{ + label: 'Number of activity test results', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ biochemical_tests_count_by_name.values }} + }] + }; + + drawBarChart('bioch_tests_histo', + biochTestData, + 'Biochemical Tests', + 'biochtest'); + + var cellTestData = { + labels: {{ cellular_tests_count_by_name.labels|safe }}, + datasets: [{ + label: 'Number of activity test results', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ cellular_tests_count_by_name.values }} + }] + }; + + drawBarChart('cell_tests_histo', + cellTestData, + 'Cellular Tests', + 'celltest'); + + var bindingDataPerPPIFamily = { + labels: {{ compounds_per_ppi_family.labels|safe }}, + datasets: [ + { + label: 'Number of binding data', + backgroundColor: "rgba(46,87,139,0.6)", + borderColor: "rgba(46,87,139,1)", + borderWidth: 1, + data: {{ binding_data_per_ppi_family.values }} + }, + { + label: 'Number of unique compounds', + backgroundColor: "rgba(185,45,92,1)", + borderColor: "rgba(185,45,92,0.6)", + borderWidth: 1, + data: {{ compounds_per_ppi_family.values }} + }, + ] + }; + + drawBarChart('data_per_ppi_family', + bindingDataPerPPIFamily, + 'Compounds and binding data available in iPPI-DB per PPI target' + ); + + + var bindingDataPerPXC50Bins = { + labels: ['Biochemical', 'Cellular'], + datasets: [ + { + label: 'pXC50>=8', + backgroundColor: "rgba(46,87,139,1)", + borderColor: "rgba(46,87,139,1)", + borderWidth: 1, + data: [{{cell_tests_pxc50_gte8}},{{bioch_tests_pxc50_gte8}}], + }, + { + label: '8>pXC50>=7', + backgroundColor: "rgba(185,45,92,1)", + borderColor: "rgba(185,45,92,1)", + borderWidth: 1, + data: [{{cell_tests_pxc50_gte7_lt8}},{{bioch_tests_pxc50_gte7_lt8}}], + }, + { + label: '7>pXC50>=6', + backgroundColor: "rgba(209,224,253,1)", + borderColor: "rgba(209,224,253,1)", + borderWidth: 1, + data: [{{cell_tests_pxc50_gte6_lt7}},{{bioch_tests_pxc50_gte6_lt7}}], + }, + { + label: '6>pXC50', + backgroundColor: "rgba(242,202,255,1)", + borderColor: "rgba(242,202,255,1)", + borderWidth: 1, + data: [{{cell_tests_pxc50_lt6}},{{bioch_tests_pxc50_lt6}}], + } + ] + }; + + drawHorizontalStackedBarChart('pxc_by_test_type', + bindingDataPerPXC50Bins, + 'Distribution of the binding data across bins of activity in pXC50 units'); + + drawCompoundsBiplotChart('le_lle_biplot', preparePerFamilyBiplotData({{ le_lle_biplot_data | safe }}), 'pharmacology'); + +</script> +{% endblock %} diff --git a/ippisite/ippidb/templates/about-physicochemistry.html b/ippisite/ippidb/templates/about-physicochemistry.html new file mode 100644 index 0000000000000000000000000000000000000000..fe928ae4c64ebf0a507d8c58f5dfec73448decb1 --- /dev/null +++ b/ippisite/ippidb/templates/about-physicochemistry.html @@ -0,0 +1,193 @@ +{% extends "about.html" %} + +{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} + +{% block pagetitle %}PHYSICOCHEMISTRY{% endblock%} + +{% block view_content %} +<div class="row"> + <div class="card col-sm-12 col-md-4"> + <canvas id="fsp3_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="mw_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="chiral_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="arom_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="rotbonds_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="haccept_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="hdon_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="tpsa_dist" style="width:300px; height:200px;"></canvas> + </div> + <div class="card col-sm-12 col-md-4"> + <canvas id="alogp_dist" style="width:300px; height:200px;"></canvas> + </div> +</div> +<script> + + var fsp3Data = { + labels: {{ fsp3_dist.labels|safe }}, + datasets: [{ + label: 'Compounds in FSP3 range', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ fsp3_dist.values }} + }] + }; + + drawBarChart('fsp3_dist', + fsp3Data, + 'Fsp3', + null, + 'bar'); + + var mwData = { + labels: {{ mw_dist.labels|safe }}, + datasets: [{ + label: 'Molecular Weight', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ mw_dist.values }} + }] + }; + + drawBarChart('mw_dist', + mwData, + 'Molecular Weight', + null, + 'bar'); + + var chiralData = { + labels: {{ chiral_dist.labels|safe }}, + datasets: [{ + label: 'Number of chiral centers', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ chiral_dist.values }} + }] + }; + + drawBarChart('chiral_dist', + chiralData, + 'Number of chiral centers', + null, + 'bar'); + + var aromData = { + labels: {{ arom_dist.labels|safe }}, + datasets: [{ + label: 'Number of aromatic rings', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ arom_dist.values }} + }] + }; + + drawBarChart('arom_dist', + aromData, + 'Number of aromatic rings', + null, + 'bar'); + + var rotbondsData = { + labels: {{ rotbonds_dist.labels|safe }}, + datasets: [{ + label: 'Number of rotatable bonds', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ rotbonds_dist.values }} + }] + }; + + drawBarChart('rotbonds_dist', + rotbondsData, + 'Number of rotatable bonds', + null, + 'bar'); + + var hacceptData = { + labels: {{ haccept_dist.labels|safe }}, + datasets: [{ + label: 'Number of H acceptors', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ haccept_dist.values }} + }] + }; + + drawBarChart('haccept_dist', + hacceptData, + 'Number of H acceptors', + null, + 'bar'); + + var hdonData = { + labels: {{ hdon_dist.labels|safe }}, + datasets: [{ + label: 'Number of H donors', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ hdon_dist.values }} + }] + }; + + drawBarChart('hdon_dist', + hdonData, + 'Number of H donors', + null, + 'bar'); + + var tpsaData = { + labels: {{ tpsa_dist.labels|safe }}, + datasets: [{ + label: 'TPSA', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ tpsa_dist.values }} + }] + }; + + drawBarChart('tpsa_dist', + tpsaData, + 'TPSA', + null, + 'bar'); + + var alogpData = { + labels: {{ alogp_dist.labels|safe }}, + datasets: [{ + label: 'ALogP', + backgroundColor: "rgba(70,130,180,0.6)", + borderColor: "rgba(70,130,180,1)", + borderWidth: 1, + data: {{ alogp_dist.values }} + }] + }; + + drawBarChart('alogp_dist', + alogpData, + 'ALogP', + null, + 'bar'); + +</script> +{% endblock %} diff --git a/ippisite/ippidb/templates/about.html b/ippisite/ippidb/templates/about.html index 799b064161e5aeb9ef8c3255b303d98701dbc2d3..367f3e3a3915965b3d6d5ca4b0bec2c538040192 100644 --- a/ippisite/ippidb/templates/about.html +++ b/ippisite/ippidb/templates/about.html @@ -4,42 +4,31 @@ {% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} {% block content %} -{% block secondarynav %} <div id="mainnav"> <nav class="secondary-nav"> <div class="inner-wrap"> <ul> <li> - <a href="/about/general">General informations</a> + <a href="/about-general">General information</a> </li> <li> - <a href="/about/pharmacology">Pharmacology</a> + <a href="/about-pharmacology">Pharmacology</a> </li> <li> - <a href="/about/physicochemistry">Physicochemistry</a> - </li> - <li> - <a href="/about/drug-candidate">Drug candidate</a> + <a href="/about-physicochemistry">Physicochemistry</a> </li> </ul> </div> </nav> </div> -{% endblock %} <div class="inner-wrap"> - <nav class="breadcrumb breadNav" role="navigation"> - <div class="breadNav-label">You are here</div> - <div aria-labelledby="breadcrumb-label"> - {% block breadcrumb %} {{block.super}}About{% endblock %} - </div> - </nav> <div id="main-wrapper" class="page"> <div id="main"> <div id="content" class="main-content"> <div class="section"> <main role="main"> - <h1 class="page-title"> ABOUT </h1> + <h1 class="page-title"> {% block pagetitle %}ABOUT{% endblock%} </h1> <div class="tabs"></div> <div class="main__inner"> <div class="region region-content"> @@ -50,7 +39,8 @@ <div class="block block-system block-system-main"> <div class="content"> <div class="view-content"> - +{% block view_content %} +{% endblock %} </div> </div> </div> diff --git a/ippisite/ippidb/templates/base.html b/ippisite/ippidb/templates/base.html index 18a1e3d53942fb9d312c48def1d1134858746134..13b7b497202ba061d73e2a5685f79073a12630a5 100644 --- a/ippisite/ippidb/templates/base.html +++ b/ippisite/ippidb/templates/base.html @@ -51,16 +51,19 @@ window.location = modifiedUrl; $('#loadingModal').modal(); }; + var changeSelection = function(paramName){ var selectedFields = $('input[name='+ paramName +']:checked').map(function(_, el) { return $(el).val(); }).get(); modifyUrl(paramName, selectedFields); } + var removeFromSelection = function(paramName, value){ var url = new URL(location.href); var selectedValues = url.searchParams.getAll(paramName); selectedValues.splice(selectedValues.indexOf(value), 1); modifyUrl(paramName, selectedValues); } + var multiselectTypeAhead = function(idSearch, selection, onSelect){ var bh = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), @@ -130,7 +133,7 @@ maintainAspectRatio: false }}); }; - var drawCompoundsBiplotChart = function(canvasId, compoundId, compoundFamily, plotData, tabHash){ + var prepareCompoundFamilyBiplotData = function(compoundId, compoundFamily, plotData){ var currentCompoundData = []; var currentFamilyData = []; var otherFamiliesData = []; @@ -162,6 +165,55 @@ data: currentCompoundData } ]}; + return scatterData; + } + + var getPpiFamilyColor = function(ppiName){ + return { + 'BCL2-Like / BAX': '#0E5C97', + 'Beta-catenin / TCF-4': '#FAB362', + 'Bromodomain / Histone': '#C9862D', + 'CD4 / gp120': '#FE8E85', + 'CD80 / CD28': '#DB0016', + 'E2 / E1': '#C4ADD1', + 'FAK / VEGFR3': '#6700FF', + 'IL2 / IL2R': '#FE6C00', + 'LEDGF / IN': '#971D19', + 'LFA / ICAM': '#9DD87E', + 'MDM2-Like / P53': '#96C5DC', + 'MENIN / MLL': '#EDBBFF', + 'Myc / Max': '#C04DC4', + 'NRP / VEGF': '#A8184B', + 'UPAR / UPA': '#CBDCFF', + 'VEGF / VEGFR': '#FED215', + 'WDR5/MLL': '#F5F6F7', + 'XIAP / Smac': '#128C6D', + 'ZipA / ftsZ': '#FEFE01', + }[ppiName]; + } + + var preparePerFamilyBiplotData = function(plotData){ + var property = 'family_name'; + var datasets = plotData.reduce(function (acc, obj) { + var family = obj[property]; + if(!acc[family]){ + acc[family] = { + label: family, + borderColor: getPpiFamilyColor(family), + backgroundColor: getPpiFamilyColor(family), + data: [] + }; + } + acc[family].data.push(obj); + return acc; + }, {}); + var scatterData = { + 'datasets': Object.values(datasets) + }; + return scatterData; + } + + var drawCompoundsBiplotChart = function(canvasId, scatterData, tabHash){ var ctx = document.getElementById(canvasId).getContext('2d'); var scatterChart = new Chart(ctx, { type: 'scatter', @@ -231,6 +283,7 @@ window.location = '/compounds/' + id + '#' + tabHash; }; }; + var setUpSliderForModal = function(paramName){ $('#'+paramName).slider(); $('#'+paramName).on('slide', function(slideEvt) { @@ -238,6 +291,7 @@ $('#'+paramName+'_textvalue_max').text(slideEvt.value[1]); }); } + var toggleCheckBox = function(id){ var cb = $('#'+id); if(cb.prop('checked')==true){ @@ -246,6 +300,82 @@ modifyUrl(id,null); } } + + var drawBarChart = function(elementId, data, caption, queryFilter, orientation){ + var ctx = document.getElementById(elementId).getContext('2d'); + if(orientation==null){ + orientation = 'horizontalBar' + } + var myHorizontalBar = new Chart(ctx, { + type: orientation, + data: data, + options: { + elements: { + rectangle: { + borderWidth: 20, + } + }, + responsive: true, + legend: { + position: 'bottom', + }, + title: { + display: true, + text: caption + } + } + }); + if(queryFilter!=null){ + document.getElementById(elementId).onclick = function(evt){ + var activePoints = myHorizontalBar.getElementAtEvent(evt); + var datasetIndex = activePoints[0]._datasetIndex; + var selectedIndex = activePoints[0]._index; + var id = myHorizontalBar.data.labels[datasetIndex]; + window.location = '/compounds/?'+ queryFilter + '=' + id; + }; + } + } + + var drawHorizontalStackedBarChart = function(elementId, data, caption, queryFilter){ + var ctx = document.getElementById(elementId).getContext('2d'); + var myHorizontalBar = new Chart(ctx, { + type: 'horizontalBar', + data: data, + options: { + elements: { + rectangle: { + borderWidth: 20, + } + }, + responsive: true, + legend: { + position: 'bottom', + }, + title: { + display: true, + text: caption + }, + scales: { + xAxes: [{ + stacked: true + }], + yAxes: [{ + stacked: true + }] + } + } + }); + if(queryFilter!=null){ + document.getElementById(elementId).onclick = function(evt){ + var activePoints = myHorizontalBar.getElementAtEvent(evt); + var datasetIndex = activePoints[0]._datasetIndex; + var selectedIndex = activePoints[0]._index; + var id = myHorizontalBar.data.labels[datasetIndex]; + window.location = '/compounds/?'+ queryFilter + '=' + id; + }; + } + } + </script> </head> @@ -277,7 +407,7 @@ <a href="/">Home</a> </li> <li> - <a href="/about">About</a> + <a href="/about-general">About</a> </li> <li> <a href="/compounds">Query compounds</a> @@ -323,7 +453,7 @@ <nav> <ul> <li> - <a href="/about">About Us</a> + <a href="/about-general">About Us</a> </li> <li> <a href="/query">Query</a> diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index ba50ab9442120e6841f61efebb475ec905c5076b..8bf98f4eff53cf2d8b98c7c21fed138d47ce94d5 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -125,7 +125,7 @@ <canvas id="pca_biplot" style="width:600px; height:600px;"></canvas> <script> - drawCompoundsBiplotChart('pca_biplot', {{ compound.id }}, '{{ compound.best_activity_ppi_family_name|default_if_none:"No target family identified" }}', {{ pca_biplot_data | safe }}, 'physicochemistry'); + drawCompoundsBiplotChart('pca_biplot', prepareCompoundFamilyBiplotData({{ compound.id }}, '{{ compound.best_activity_ppi_family_name|default_if_none:"No target family identified" }}', {{ pca_biplot_data | safe }}), 'physicochemistry'); </script> </div> </div> @@ -143,7 +143,7 @@ <div class="card-body"> <canvas id="le_lle_biplot"></canvas> <script> - drawCompoundsBiplotChart('le_lle_biplot', {{ compound.id }}, '{{ compound.best_activity_ppi_family_name|default_if_none:"No target family identified" }}', {{ le_lle_biplot_data | safe }}, 'pharmacology'); + drawCompoundsBiplotChart('le_lle_biplot', prepareCompoundFamilyBiplotData({{ compound.id }}, '{{ compound.best_activity_ppi_family_name|default_if_none:"No target family identified" }}', {{ le_lle_biplot_data | safe }}), 'pharmacology'); </script> </div> </div> diff --git a/ippisite/ippidb/templates/general.html b/ippisite/ippidb/templates/general.html deleted file mode 100644 index 7c1f459a6b09ff44203867969380ca345b199074..0000000000000000000000000000000000000000 --- a/ippisite/ippidb/templates/general.html +++ /dev/null @@ -1,64 +0,0 @@ -{% extends "about.html" %} - - -{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} - -{% block content %} -<div id="mainnav"> - <nav class="secondary-nav"> - <div class="inner-wrap"> - <ul> - <li> - <a href="/about/general">General informations</a> - </li> - <li> - <a href="/about/pharmacology">Pharmacology</a> - </li> - <li> - <a href="/about/physicochemistry">Physicochemistry</a> - </li> - <li> - <a href="/about/drug-candidate">Drug Candidate</a> - </li> - </ul> - </div> - </nav> -</div> -<div class="inner-wrap"> - <nav class="breadcrumb breadNav" role="navigation"> - <div class="breadNav-label">You are here</div> - <div aria-labelledby="breadcrumb-label"> - {% block breadcrumb %} <a href="/about" class="breadNav-link">{{block.super}}</a> > General informations {% endblock %} - </div> - </nav> - <div id="main-wrapper" class="page"> - <div id="main"> - <div id="content" class="main-content"> - <div class="section"> - <main role="main"> - <h1 class="page-title"> GENERAL INFORMATIONS </h1> - <div class="tabs"></div> - <div class="main__inner"> - <div class="region region-content"> - <div class="page-intro"> - </div> - <div class="color-wrap"> - <div class="region region-content"> - <div class="block block-system block-system-main"> - <div class="content"> - <div class="view-content"> - - </div> - </div> - </div> - </div> - </div> - </div> - </div> - </main><!-- .site-main --> - </div> - </div> - </div><!-- div main --> - </div> -</div> -{% endblock %} diff --git a/ippisite/ippidb/templates/physicochemistry.html b/ippisite/ippidb/templates/physicochemistry.html deleted file mode 100644 index 0f6a83098645b491b1626b003d81d88e0ea7c9ea..0000000000000000000000000000000000000000 --- a/ippisite/ippidb/templates/physicochemistry.html +++ /dev/null @@ -1,64 +0,0 @@ -{% extends "about.html" %} - - -{% block title %}inhibitors of Protein-Protein Interaction Database{% endblock %} - -{% block content %} -<div id="mainnav"> - <nav class="secondary-nav"> - <div class="inner-wrap"> - <ul> - <li> - <a href="/about/general">General informations</a> - </li> - <li> - <a href="/about/pharmacology">Pharmacology</a> - </li> - <li> - <a href="/about/physicochemistry">Physicochemistry</a> - </li> - <li> - <a href="/about/drug-candidate">Drug candidate</a> - </li> - </ul> - </div> - </nav> -</div> -<div class="inner-wrap"> - <nav class="breadcrumb breadNav" role="navigation"> - <div class="breadNav-label">You are here</div> - <div aria-labelledby="breadcrumb-label"> - {% block breadcrumb %} <a href="/about/" class="breadNav-link">{{block.super}}</a> > Physicochemistry {% endblock %} - </div> - </nav> - <div id="main-wrapper" class="page"> - <div id="main"> - <div id="content" class="main-content"> - <div class="section"> - <main role="main"> - <h1 class="page-title"> PHYSICOCHEMISTRY </h1> - <div class="tabs"></div> - <div class="main__inner"> - <div class="region region-content"> - <div class="page-intro"> - </div> - <div class="color-wrap"> - <div class="region region-content"> - <div class="block block-system block-system-main"> - <div class="content"> - <div class="view-content"> - - </div> - </div> - </div> - </div> - </div> - </div> - </div> - </main><!-- .site-main --> - </div> - </div> - </div><!-- div main --> - </div> -</div> -{% endblock %} diff --git a/ippisite/ippidb/urls.py b/ippisite/ippidb/urls.py index d112f740a8c1a73da522779d333c666380eaa6d4..bb3f766bb593b5c7dff6b47bc75648c132f06417 100644 --- a/ippisite/ippidb/urls.py +++ b/ippisite/ippidb/urls.py @@ -13,8 +13,9 @@ ippidb_wizard = IppiWizard.as_view(FORMS, urlpatterns = [ url(r'^$', views.index, name='index'), - url(r'^about$', views.about, name='about'), - url(r'^about/general/$', views.general, name='general'), + url(r'^about-general/$', views.about_general, name='general'), + url(r'^about-pharmacology/$', views.about_pharmacology, name='pharmacology'), + url(r'^about-physicochemistry/$', views.about_physicochemistry, name='physicochemistry'), url(r'^compounds/$', views.CompoundListView.as_view(), name='compound_list'), url(r'^compounds/IPPIDB-(?P<compound_id>\w+)$', views.CompoundCardBDCHEMRedirectView.as_view(), name='redirect_compound_card'), url(r'^compounds/(?P<pk>\w+)$', views.CompoundDetailView.as_view(), name='compound_card'), diff --git a/ippisite/ippidb/views/__init__.py b/ippisite/ippidb/views/__init__.py index 377175cfd797a046f62fd0c6061dde5632c5b004..1eb3e43b4bd8c8c13ab43c0d52c48b1820f5a74a 100644 --- a/ippisite/ippidb/views/__init__.py +++ b/ippisite/ippidb/views/__init__.py @@ -18,11 +18,6 @@ from django.conf import settings def index(request): return render(request, 'index.html') - -def about(request): - return render(request, 'about.html') - - def general(request): return render(request, 'general.html') diff --git a/ippisite/ippidb/views/compound_query.py b/ippisite/ippidb/views/compound_query.py index 532f9f5a4d630b52f2f94c918a7a4abe82116005..f35de390859c77b7e0a596b26aed3612cee79e01 100644 --- a/ippisite/ippidb/views/compound_query.py +++ b/ippisite/ippidb/views/compound_query.py @@ -5,7 +5,8 @@ iPPI-DB compound query view and related classes import json from collections import OrderedDict -from django.db.models import Max, Min, F, Q +from django.db.models import Max, Min, F, Q, Count, FloatField +from django.db.models.functions import Cast, Floor from django.shortcuts import render from django.urls import reverse from django.http import Http404, JsonResponse @@ -14,7 +15,7 @@ from django.views.generic.detail import DetailView from django.views.generic.base import RedirectView from ippidb.utils import mol2smi, smi2mol -from ippidb.models import Compound, Ppi, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Disease, Domain, Taxonomy, LeLleBiplotData, PcaBiplotData, PpiFamily, MolecularFunction, TestActivityDescription, create_tanimoto +from ippidb.models import Compound, Ppi, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Disease, Domain, Taxonomy, LeLleBiplotData, PcaBiplotData, PpiFamily, MolecularFunction, TestActivityDescription, create_tanimoto, CompoundActivityResult, Bibliography, Protein DEACTIVATION_MAPPING = { 'lipinsky': set(['molecular_weight', 'nb_acceptor_h', 'nb_donor_h', 'a_log_p']), @@ -551,3 +552,79 @@ def convert_smi2mol(request): mol_string = smi2mol(smi_string) resp = {'mol': mol_string} return JsonResponse(resp) + +def about_general(request): + compounds_count = Compound.objects.count() + car_count = CompoundActivityResult.objects.count() + bioch_car_count = CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').count() + cell_car_count = CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').count() + proteins_count = Protein.objects.count() + families_count = PpiFamily.objects.count() + ppis_count = Ppi.objects.count() + biblio_count = Bibliography.objects.count() + context = { + 'compounds_count': compounds_count, + 'car_count': car_count, + 'bioch_car_count': bioch_car_count, + 'cell_car_count': cell_car_count, + 'proteins_count': proteins_count, + 'families_count': families_count, + 'ppis_count': ppis_count, + 'biblio_count': biblio_count, + } + return render(request, 'about-general.html', context=context) + +def convert_to_bar_chart_data(data): + return { + 'labels': [item['label'] for item in data], + 'values': [item['value'] for item in data] + } + +def about_pharmacology(request): + biochemical_tests_count_by_name_qs = CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').values(label=F('test_activity_description__test_name')).order_by('label').annotate(value=Count('label')).order_by('-value') + biochemical_tests_count_by_name = convert_to_bar_chart_data(biochemical_tests_count_by_name_qs) + cellular_tests_count_by_name_qs = CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').values(label=F('test_activity_description__test_name')).order_by('label').annotate(value=Count('label')).order_by('-value') + cellular_tests_count_by_name = convert_to_bar_chart_data(cellular_tests_count_by_name_qs) + compounds_per_ppi_family_raw = PpiFamily.objects.annotate(value=Count('ppi__compoundaction__compound', distinct=True)).values(value=F('value'),label=F('name')).order_by('-value').all() + compounds_per_ppi_family = convert_to_bar_chart_data(compounds_per_ppi_family_raw) + binding_data_per_ppi_family_raw = PpiFamily.objects.annotate(value=Count('ppi__compoundaction')).values(value=F('value'),label=F('name')).order_by('-value') + binding_data_per_ppi_family = convert_to_bar_chart_data(binding_data_per_ppi_family_raw) + context = { + 'biochemical_tests_count_by_name': biochemical_tests_count_by_name, + 'cellular_tests_count_by_name': cellular_tests_count_by_name, + 'bioch_tests_pxc50_gte8': CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').filter(activity__gte=8).count(), + 'bioch_tests_pxc50_gte7_lt8': CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').filter(activity__gte=7).filter(activity__lt=8).count(), + 'bioch_tests_pxc50_gte6_lt7': CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').filter(activity__gte=6).filter(activity__lt=7).count(), + 'bioch_tests_pxc50_lt6': CompoundActivityResult.objects.filter(test_activity_description__test_type='BIOCH').filter(activity__lt=6).count(), + 'cell_tests_pxc50_gte8': CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').filter(activity__gte=8).count(), + 'cell_tests_pxc50_gte7_lt8': CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').filter(activity__gte=7).filter(activity__lt=8).count(), + 'cell_tests_pxc50_gte6_lt7': CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').filter(activity__gte=6).filter(activity__lt=7).count(), + 'cell_tests_pxc50_lt6': CompoundActivityResult.objects.filter(test_activity_description__test_type='CELL').filter(activity__lt=6).count(), + 'compounds_per_ppi_family': compounds_per_ppi_family, + 'binding_data_per_ppi_family': binding_data_per_ppi_family, + 'le_lle_biplot_data': LeLleBiplotData.objects.get().le_lle_biplot_data, + } + return render(request, 'about-pharmacology.html', context=context) + +def about_physicochemistry(request): + fsp3_counts = Compound.objects.annotate(label=Cast(Floor(F('fsp3')*10),FloatField())/10).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + mw_counts = Compound.objects.annotate(label=Cast(Floor(F('molecular_weight')/100),FloatField())*100).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + chiral_counts = Compound.objects.annotate(label=F('nb_chiral_centers')).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + arom_counts = Compound.objects.annotate(label=F('nb_aromatic_sssr')).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + rotbonds_counts = Compound.objects.annotate(label=F('nb_rotatable_bonds')).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + haccept_counts = Compound.objects.annotate(label=F('nb_acceptor_h')).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + hdon_counts = Compound.objects.annotate(label=F('nb_donor_h')).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + tpsa_counts = Compound.objects.annotate(label=Cast(Floor(F('tpsa')/10),FloatField())*10).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + alogp_counts = Compound.objects.annotate(label=Cast(Floor(F('a_log_p')),FloatField())).values('label').order_by('label').annotate(value=Count('label')).values('value','label').exclude(value=0) + context = { + 'fsp3_dist': convert_to_bar_chart_data(fsp3_counts), + 'mw_dist': convert_to_bar_chart_data(mw_counts), + 'chiral_dist': convert_to_bar_chart_data(chiral_counts), + 'arom_dist': convert_to_bar_chart_data(arom_counts), + 'rotbonds_dist': convert_to_bar_chart_data(rotbonds_counts), + 'haccept_dist': convert_to_bar_chart_data(haccept_counts), + 'hdon_dist': convert_to_bar_chart_data(hdon_counts), + 'tpsa_dist': convert_to_bar_chart_data(tpsa_counts), + 'alogp_dist': convert_to_bar_chart_data(alogp_counts), + } + return render(request, 'about-physicochemistry.html', context=context)