Commit cf03f544 authored by Fabien  MAREUIL's avatar Fabien MAREUIL
Browse files

ctrl click pockets network and default isolevel value

parent da0501a0
......@@ -18,6 +18,17 @@ def dir_path(string):
raise NotADirectoryError(string)
def isolevel_float(arg):
""" Type function for argparse - a float within some predefined bounds """
try:
f = float(arg)
except ValueError:
raise argparse.ArgumentTypeError("Must be a floating point number")
if f < 0 or f > 1.0:
raise argparse.ArgumentTypeError("Argument must be < 1.0 and > 0")
return f
class Command(AppCommand):
"""
Command to update mrc files
......@@ -26,7 +37,12 @@ class Command(AppCommand):
help = "liste all mrc files in a directory and update files in the database"
def __init__(
self, stdout=None, stderr=None, no_color=False, force_color=False, task=None,
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
......@@ -38,7 +54,10 @@ class Command(AppCommand):
def add_arguments(self, parser):
parser.add_argument(
"-mp", "--mrcpath", type=dir_path, help="root directory with all mrc files",
"-mp",
"--mrcpath",
type=dir_path,
help="root directory with all mrc files",
)
parser.add_argument(
"-pa",
......@@ -61,6 +80,14 @@ class Command(AppCommand):
dest="label",
help="label for files, used as label in the interface",
)
parser.add_argument(
"-di",
"--default_isolevel",
dest="default_isolevel",
help="isolevel default value",
default=0.7,
type=isolevel_float,
)
def handle(self, *args, **options):
"""
......@@ -75,7 +102,9 @@ class Command(AppCommand):
if typefile == "druggability":
storage_path = Chain.mrc_file.field.storage.path("content/mrc_files")
else:
storage_path = InteractFile.interact_file.field.storage.path("content/interact_files")
storage_path = InteractFile.interact_file.field.storage.path(
"content/interact_files"
)
if not os.path.exists(storage_path):
os.makedirs(storage_path)
list_files = glob.glob(os.path.join(mrcpath, pattern))
......@@ -108,13 +137,18 @@ class Command(AppCommand):
with open(data, "rb") as f:
dbchains[0].mrc_file.delete()
dbchains[0].mrc_file.save(os.path.basename(data), File(f))
dbchains[0].default_isolevel = options["default_isolevel"]
dbchains[0].save()
else:
interactfile, created = InteractFile.objects.get_or_create(
chain=dbchains[0], label=label
chain=dbchains[0],
label=label,
)
with open(data, "rb") as f:
interactfile.interact_file.delete()
interactfile.interact_file.save(os.path.basename(data), File(f))
interactfile.default_isolevel=options["default_isolevel"]
interactfile.save()
self.stdout.write(
self.style.SUCCESS(
"File mrc {}, have been saved in Chain, pdb: {}, chain: {}".format(
......@@ -126,7 +160,8 @@ class Command(AppCommand):
self.stdout.write(
self.style.WARNING(
"WARNING: Chain, pdb: {}, chain: {} doesn't exist".format(
pdb, chain,
pdb,
chain,
)
)
)
# Generated by Django 2.2.1 on 2021-03-10 10:52
from django.db import migrations, models
def init_isolevel(apps, schema_editor):
Chain = apps.get_model("ippidb", "Chain")
InteractFile = apps.get_model("ippidb", "InteractFile")
Chains = Chain.objects.all()
if Chains:
for Chain in Chains:
Chain.default_isolevel = 0.5
Chain.save()
InteractFiles = InteractFile.objects.all()
if InteractFiles:
for InteractFile in InteractFiles:
if InteractFile.label == "all":
InteractFile.default_isolevel = 0.7
InteractFile.save()
if InteractFile.label == "hydrophobic":
InteractFile.default_isolevel = 0.3
InteractFile.save()
if InteractFile.label == "hbond donor-acceptor":
InteractFile.default_isolevel = 0.3
InteractFile.save()
if InteractFile.label == "negative":
InteractFile.default_isolevel = 0.08
InteractFile.save()
if InteractFile.label == "positive":
InteractFile.default_isolevel = 0.05
InteractFile.save()
if InteractFile.label == "backbone":
InteractFile.default_isolevel = 0.18
InteractFile.save()
class Migration(migrations.Migration):
dependencies = [
("ippidb", "0067_metainformation_normalize_factor"),
]
operations = [
migrations.AddField(
model_name="chain",
name="default_isolevel",
field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
),
migrations.AddField(
model_name="interactfile",
name="default_isolevel",
field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
),
migrations.RunPython(init_isolevel, reverse_code=migrations.RunPython.noop),
]
......@@ -132,6 +132,9 @@ class Chain(models.Model):
verbose_name="pdb file content with only one chain", default="no pdb file"
)
mrc_file = models.FileField(upload_to=content, blank=True)
default_isolevel = models.FloatField(
default=0.7, verbose_name="Default isolevel value"
)
class Meta:
unique_together = ("pdb", "pdb_chain_id")
......@@ -156,6 +159,9 @@ class InteractFile(models.Model):
chain = models.ForeignKey(Chain, on_delete=models.CASCADE)
label = models.CharField(max_length=250, blank=False, null=False)
interact_file = models.FileField(upload_to=contentinteract, blank=True)
default_isolevel = models.FloatField(
default=0.7, verbose_name="Default isolevel value"
)
def __unicode__(self):
return "{}".format(self.interact_file)
......
......@@ -57,7 +57,7 @@ class ChainDistanceSerializer(serializers.ModelSerializer):
class Meta:
model = Chain
fields = ("id", "pdb_chain_id", "protein", "pdb")
fields = ("id", "pdb_chain_id", "protein", "pdb", "default_isolevel")
class PartnerDistanceSerializer(serializers.ModelSerializer):
......@@ -121,6 +121,7 @@ class ChainSerializer(serializers.ModelSerializer):
"cavity_set",
"partner_set",
"mrc_file",
"default_isolevel",
"interactfile_set",
)
......
......@@ -448,13 +448,13 @@ function loadNGL(url, callback){
opaqueBack: false,
smooth: 2,
color: filecolor(indexchain, indexfile),
isolevel: 0.7,
isolevel: interactfile.default_isolevel,
isolevelType: 'value',});
});
var divvalueslider = createElement("div", {}, {}, "", {'id': baseName(interactfile.interact_file) + "_interact_isolevel"});
divvalueslider.innerHTML = 'current value for ' + interactfile.label + ': 0.7';
divvalueslider.innerHTML = 'current value for ' + interactfile.label + ': ' + interactfile.default_isolevel;
divchain.appendChild(divvalueslider);
var isolevel = createElement("input", {type: "range", value: 70, min: 0, max: 100, step: 1},
var isolevel = createElement("input", {type: "range", value: interactfile.default_isolevel*100, min: 0, max: 100, step: 1},
{},"form-control-range",{'id': baseName(interactfile.interact_file) + "_interact_isolevelslide"});
isolevel.oninput = function(e) {
$('#' + baseName(interactfile.interact_file) + "_interact_isolevel").html('current value for ' + interactfile.label + ': ' + parseFloat(e.target.value)/100);
......@@ -485,7 +485,7 @@ function loadNGL(url, callback){
opaqueBack: false,
smooth: 2,
color: filecolor(indexchain, -1),
isolevel: 0.7,
isolevel: chain.default_isolevel,
isolevelType: 'value',});
});
......@@ -493,11 +493,11 @@ function loadNGL(url, callback){
var labelslider = createElement("label", {}, {}, "", {'for':'isolevel' + chain.pdb_chain_id});
labelslider.innerHTML = 'Adjust predictive surface druggable on chain ' + chain.pdb_chain_id;
var divvalueslider = createElement("div", {}, {}, "", {'id': 'valueisolevel' + chain.pdb_chain_id});
divvalueslider.innerHTML = 'current value: 0.7'
divvalueslider.innerHTML = 'current value: '+ chain.default_isolevel
divchainmrc.appendChild(labelslider);
divchainmrc.appendChild(divvalueslider);
var isolevel = createElement("input", {
type: "range", value: 70, min: 0, max: 100, step: 1
type: "range", value: chain.default_isolevel*100, min: 0, max: 100, step: 1
}, {},"form-control-range",{'id':'isolevel' + chain.pdb_chain_id});
isolevel.oninput = function(e) {
$('#valueisolevel' + chain.pdb_chain_id).html('current value: ' + parseFloat(e.target.value)/100);
......
......@@ -71,6 +71,9 @@ var node_trace = function(nodes, edges) {
return [trace_edges, trace_PL, trace_HD, dict_nodes, [size_PL, size_HD]]
};
var pathurl = window.location.pathname.split( '/' );
pathurl.pop();
var base_url = window.location.origin + pathurl.join('/')
var build_trace = function(nodes, edges) {
traces = node_trace(nodes, edges);
......@@ -99,26 +102,34 @@ $.ajax({
Plotly.newPlot('myDiv', [data[0], data[1], data[2]], layout, {scrollZoom: true});
$(".loader").remove();
ippidb_plot.on('plotly_click', function(datapoints){
var curvenumber = datapoints.points[0].curveNumber - 1;
var pointnumber = datapoints.points[0].pointNumber;
var colors = [repeatElement("#4e79a7", connect_ippidb[0].length),
repeatElement("#de425b", connect_ippidb[1].length)];
var opacity = [repeatElement(0.2, connect_ippidb[0].length),
repeatElement(0.2, connect_ippidb[1].length)];
colors[curvenumber][pointnumber] = '#488f31';
opacity[curvenumber][pointnumber] = 1;
for (var i=0; i < connect_ippidb[curvenumber][pointnumber].length; i++){
var curvenumber2 = connect_ippidb[curvenumber][pointnumber][i][0];
var pointnumber2 = connect_ippidb[curvenumber][pointnumber][i][1];
colors[curvenumber2][pointnumber2] = '#488f31';
opacity[curvenumber2][pointnumber2] = 1;
}
var update_PL = {'marker':{color: colors[0], size: data[4][0], line: {width: 1,
color: 'DarkSlateGrey'}, opacity: opacity[0], symbol: 1}};
var update_HD = {'marker':{color: colors[1], size: data[4][1], line: {width: 1,
color: 'DarkSlateGrey'}, opacity: opacity[1]}};
Plotly.restyle('myDiv', update_PL, 1);
Plotly.restyle('myDiv', update_HD, 2);
if (datapoints.event.button == 0) {
if (datapoints.event.ctrlKey) {
window.open(base_url + "/?pdbsearch=" + datapoints.points[0].text.split("-")[0], '_blank');
} else {
var curvenumber = datapoints.points[0].curveNumber - 1;
var pointnumber = datapoints.points[0].pointNumber;
var colors = [repeatElement("#4e79a7", connect_ippidb[0].length),
repeatElement("#de425b", connect_ippidb[1].length)];
var opacity = [repeatElement(0.2, connect_ippidb[0].length),
repeatElement(0.2, connect_ippidb[1].length)];
colors[curvenumber][pointnumber] = '#488f31';
opacity[curvenumber][pointnumber] = 1;
for (var i=0; i < connect_ippidb[curvenumber][pointnumber].length; i++){
var curvenumber2 = connect_ippidb[curvenumber][pointnumber][i][0];
var pointnumber2 = connect_ippidb[curvenumber][pointnumber][i][1];
colors[curvenumber2][pointnumber2] = '#488f31';
opacity[curvenumber2][pointnumber2] = 1;
}
var update_PL = {'marker':{color: colors[0], size: data[4][0], line: {width: 1,
color: 'DarkSlateGrey'}, opacity: opacity[0], symbol: 1}};
var update_HD = {'marker':{color: colors[1], size: data[4][1], line: {width: 1,
color: 'DarkSlateGrey'}, opacity: opacity[1]}};
Plotly.restyle('myDiv', update_PL, 1);
Plotly.restyle('myDiv', update_HD, 2);
};
};
});
$('.search-button').click(function() {
......
......@@ -35,6 +35,10 @@
<span>Vicinity network of the PPI pocketome: Displays pockets having a pocket similarity index (PSI) with at least one other pocket above 0.65
<br><br>Vicinity network of PPI pockets (non-redundant): Same as above but by only considering similar pockets within proteins having a different Uniprot ID.
The purpose is this network is to highlight unforeseen vicinities within the PPI pocketome.
<br> <br>
mouse left-click pocket to show closest pockets
<br>
mouse left-click + ctrl key on pocket to load details on protein (pockets, 3d structure, pockets descriptors...)
</span>
</a>
</p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment