diff --git a/ippisite/db.sqlite3.REMOVED.git-id b/ippisite/db.sqlite3.REMOVED.git-id index d23a7914fd588b82f000b3e0267b142b66545d6d..6947594a004734b22c1379e7cd8508df245fdf87 100644 --- a/ippisite/db.sqlite3.REMOVED.git-id +++ b/ippisite/db.sqlite3.REMOVED.git-id @@ -1 +1 @@ -b3413ac6f067ab89b2dad63c444b3021ffeef640 \ No newline at end of file +8e1155c407f37772a3cec105df9f551c3bbe8232 \ No newline at end of file diff --git a/ippisite/ippidb/management/commands/lle_le.py b/ippisite/ippidb/management/commands/lle_le.py index 8b87716aec706faef21b07c9453d9cc2a2e1a965..6a0d08c8e740fbdab4aed42ca712fcb87301db94 100644 --- a/ippisite/ippidb/management/commands/lle_le.py +++ b/ippisite/ippidb/management/commands/lle_le.py @@ -1,9 +1,10 @@ import glob +import json from django.utils import timezone from django.core.management import BaseCommand, CommandError -from ippidb.models import Compound +from ippidb.models import Compound, LeLleBiplotData class Command(BaseCommand): @@ -11,9 +12,16 @@ class Command(BaseCommand): def handle(self, *args, **options): self.stdout.write(self.style.SUCCESS('Generating the LE vs. LLE biplot...')) + le_lle_data = [] + LeLleBiplotData.objects.all().delete() + self.stdout.write( + self.style.SUCCESS('Successfully flushed LE-LLE biplot data table')) for comp in Compound.objects.all(): - print(comp.id, comp.le, comp.lle) - #df = Compound.objects.all().to_dataframe() - #df['le']=df[ - #print(df.to_csv()) - #print(df.columns) + le = round(comp.le, 7) + lle = round(comp.lle, 7) + le_lle_data.append({'x': le, 'y': lle, 'id': comp.id, 'family':'TBD'}) + le_lle_json = json.dumps(le_lle_data, separators=(',',':')) + new = LeLleBiplotData() + new.le_lle_biplot_data = le_lle_json + new.save() + print(len(le_lle_json)) diff --git a/ippisite/ippidb/migrations/0032_lellebiplotdata.py b/ippisite/ippidb/migrations/0032_lellebiplotdata.py new file mode 100644 index 0000000000000000000000000000000000000000..8eae1a75f2c6df99af201b88289f1c9eb9b3b99c --- /dev/null +++ b/ippisite/ippidb/migrations/0032_lellebiplotdata.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-04-08 15:22 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ippidb', '0031_compoundactivityresult_inhibition_percentage'), + ] + + operations = [ + migrations.CreateModel( + name='LeLleBiplotData', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('le_lle_biplot_data', models.CharField(blank=True, max_length=150000, null=True, verbose_name='LE-LLE biplot JSON data')), + ], + ), + ] diff --git a/ippisite/ippidb/models.py b/ippisite/ippidb/models.py index 32cf38fddcfcc6875c4fa6eaa3ee2c2ffb66f982..0cc0f182e05f4e4eecd8077f942649e32476930f 100644 --- a/ippisite/ippidb/models.py +++ b/ippisite/ippidb/models.py @@ -422,6 +422,9 @@ class Compound(models.Model): """ return float(self.compoundactivityresult_set.aggregate(Max('activity'))['activity__max'] - self.a_log_p) +class LeLleBiplotData(models.Model): + le_lle_biplot_data = models.CharField('LE-LLE biplot JSON data', max_length=150000, blank=True, null=True) + class MDDRActivityClass(models.Model): name = models.CharField('Activity Class', max_length=100, unique=True) diff --git a/ippisite/ippidb/templates/compound_card.html b/ippisite/ippidb/templates/compound_card.html index 5a1495d024680558002b6892f81a59a386a8411a..24f97c84374811b0e430923666a6fdeb84f8fd9a 100644 --- a/ippisite/ippidb/templates/compound_card.html +++ b/ippisite/ippidb/templates/compound_card.html @@ -165,11 +165,7 @@ { label: 'Other PPI families', borderColor: "rgba(211,211,211, 0.8)", backgroundColor: "rgba(211,211,211, 0.8)", - data:[ - {% for c in all_compounds %} - {x: {{ c.le }}, y: {{ c.lle }}, id: {{ c.id }} }, - {% endfor %} - ] + data: {{ biplot_data | safe }} } ]}; var ctx = document.getElementById('le_lle_biplot').getContext('2d'); diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index 04b2f150761349be1ca53e46b19e8bcbe1666862..c72d6598f7007159aa6b48e824f329e537e139f4 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -5,7 +5,7 @@ from django.http import HttpResponseRedirect, Http404 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from formtools.wizard.views import SessionWizardView, NamedUrlSessionWizardView from .forms import IdForm, BibliographyForm, PDBForm, ProteinForm, ComplexCompositionForm, ComplexCompositionFormSet, ProteinDomainComplexTypeForm, ProteinDomainComplexForm, PpiForm, PpiComplexForm, ProteinFormSet,TestsForm, CompoundForm, CompoundFormSet -from .models import Protein, Bibliography, ProteinDomainComplex, ProteinDomainBoundComplex, RefCompoundBiblio, TestActivityDescription, Compound, Ppi, Disease, Taxonomy +from .models import Protein, Bibliography, ProteinDomainComplex, ProteinDomainBoundComplex, RefCompoundBiblio, TestActivityDescription, Compound, Ppi, Disease, Taxonomy, LeLleBiplotData from .ws import get_pdb_uniprot_mapping @@ -235,7 +235,7 @@ def compound_list(request): def compound_card(request, compound_id): try: compound = Compound.objects.get(id=int(compound_id)) - all_compounds = Compound.objects.all() except Compound.DoesNotExist: raise Http404("No compound data for %s:%s" % (compound_id)) - return render(request, 'compound_card.html', {'compound': compound, 'all_compounds': all_compounds}) + biplot_data = LeLleBiplotData.objects.get().le_lle_biplot_data + return render(request, 'compound_card.html', {'compound': compound, 'biplot_data': biplot_data})