From fce302e1bc8f29550a8ee30cd77b15ba21e5c5a7 Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Wed, 29 Jul 2015 00:30:16 +0530 Subject: [PATCH 1/7] first commit --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 325a360..f7bcb35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ biopython -django-registration-redux==1.1 -django==1.6 +django-registration-redux +django==1.8 selenium mysql-python numpy From b75decbf9842515eebbb6f511d9e63cf179cfb02 Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Thu, 13 Aug 2015 18:41:02 +0530 Subject: [PATCH 2/7] Arrtibute error --- docker-compose.yml | 2 +- pgd/settings.py | 7 +++++-- pgd/urls.py | 6 ++++-- pgd_search/plot/ConfDistFuncs.py | 2 +- pgd_search/plot/PlotForm.py | 32 ++++++++++++++++------------- pgd_search/plot/views.py | 6 +----- pgd_search/search/views.py | 8 +++----- pgd_search/statistics/aggregates.py | 1 + requirements.txt | 1 + 9 files changed, 35 insertions(+), 30 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 756d6fe..9cda14d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,4 +40,4 @@ networks: front-tier: driver: bridge back-tier: - driver: bridge + driver: bridge \ No newline at end of file diff --git a/pgd/settings.py b/pgd/settings.py index 95fc97d..5174fc3 100644 --- a/pgd/settings.py +++ b/pgd/settings.py @@ -4,9 +4,10 @@ import os PROJECT_ROOT = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) -DEBUG = config('DEBUG', default=False, cast=bool) +DEBUG = True TEMPLATE_DEBUG = DEBUG + ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) @@ -122,6 +123,7 @@ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'django_pdb.middleware.PdbMiddleware', ) ROOT_URLCONF = config('ROOT_URLCONF', default='pgd.urls') @@ -130,11 +132,12 @@ WSGI_APPLICATION = 'pgd.wsgi.application' TEMPLATE_DIRS = ( - '%s/templates' % DOC_ROOT + '%s/templates' % DOC_ROOT, ) INSTALLED_APPS = ( 'django.contrib.auth', + 'django_pdb', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', diff --git a/pgd/urls.py b/pgd/urls.py index 49f4789..f00229e 100755 --- a/pgd/urls.py +++ b/pgd/urls.py @@ -5,6 +5,8 @@ from django.core.urlresolvers import reverse_lazy from views import ReferencesView, ContactUsView, NewsView, WelcomeView admin.autodiscover() +import pgd_search.urls +import pgd_core.urls #from pgd import VERSION #from pgd_splicer.models import pdb_select_settings @@ -20,9 +22,9 @@ # Uncomment the next line to enable the admin: #(r'^admin/', include(admin.site.urls)), - url(r'^search/', include('pgd_search.urls'), name='pgd_search'), + url(r'^search/', include(pgd_search.urls), name='pgd_search'), - url(r'^accounts/', include('pgd_core.urls')), + url(r'^accounts/', include(pgd_core.urls)), # Static pages: (r'^references/$', ReferencesView.as_view()), diff --git a/pgd_search/plot/ConfDistFuncs.py b/pgd_search/plot/ConfDistFuncs.py index b040ea5..fa946c8 100644 --- a/pgd_search/plot/ConfDistFuncs.py +++ b/pgd_search/plot/ConfDistFuncs.py @@ -14,7 +14,7 @@ from pgd_constants import * from pgd_core.models import * from pgd_search.models import * -from pgd_search.statistics.aggregates import DirectionalAvg, DirectionalStdDev, BinSort +from pgd_search.statistics.aggregates import DirectionalAvg, DirectionalStdDev, BinSort, PGDAggregate from pgd_splicer.sidechain import sidechain_length_relationship_list, sidechain_angle_relationship_list from svg import * diff --git a/pgd_search/plot/PlotForm.py b/pgd_search/plot/PlotForm.py index aa66e35..d4b1acf 100644 --- a/pgd_search/plot/PlotForm.py +++ b/pgd_search/plot/PlotForm.py @@ -3,7 +3,7 @@ from pgd_search.views import RESIDUE_INDEXES #choice for occurence of property -ATTRIBUTE_CHOICES = [ +ATTRIBUTE_CHOICES = ( ("Observations",'Observations'), ("L1",u'C-1N'), ("L2",u'NCα'), @@ -28,10 +28,10 @@ ("psi",u'ψ'), ('zeta',u'ζ'), #('h_bond_energy','H Bond'), - ] + ) # choices for properties mapped to axis -PROPERTY_CHOICES = [ +PROPERTY_CHOICES = ( ("L1",u'C-1N'), ("L2",u'NCα'), ("L3",u'CαCβ'), @@ -55,7 +55,7 @@ ("psi",u'ψ'), ('zeta',u'ζ'), #('h_bond_energy','H Bond'), - ] + ) PROPERTY_CHOICES_DICT = {} @@ -63,42 +63,42 @@ PROPERTY_CHOICES_DICT[prop] = label -BACKGROUND_CHOICES = [ +BACKGROUND_CHOICES = ( ('#ffffff','White'), ('#000000','Black'), ('#666666','Gray'), ('#222222','Dark Gray'), (None,'Transparent'), -] +) -GRAPH_CHOICES = [ +GRAPH_CHOICES = ( ('#222222','Dark Gray'), ('#666666','Gray'), ('#000000','Black'), ('#ffffff','White'), (None,'Transparent'), -] +) -TEXT_CHOICES = [ +TEXT_CHOICES = ( ('#000000','Black'), ('#ffffff','White'), ('#666666','Gray'), ('#222222','Dark Gray'), -] +) -HUE_CHOICES = [ +HUE_CHOICES = ( ('green','Green'), ('blue','Blue'), ('red','Red'), ('black','Black/White'), -] +) -HASH_CHOICES = [ +HASH_CHOICES = ( ('#666666','Gray'), ('#222222','Dark Gray'), ('#000000','Black'), ('#ffffff','White'), -] +) """ @@ -165,4 +165,8 @@ def clean(self): data['attribute'] = data['attribute'].replace('-','_') except KeyError: pass + if not data['background_color'] : + data['background_color'] = 'Transparent' + if not data['graph_color'] : + data['graph_color'] = 'Transparent' return data diff --git a/pgd_search/plot/views.py b/pgd_search/plot/views.py index 2c1d612..28fbf69 100644 --- a/pgd_search/plot/views.py +++ b/pgd_search/plot/views.py @@ -6,13 +6,13 @@ from django.conf import settings from django.shortcuts import render_to_response import json - from PlotForm import PlotForm, ATTRIBUTE_CHOICES, PROPERTY_CHOICES from ConfDistFuncs import * from pgd_constants import AA_CHOICES from pgd_search.views import settings_processor from pgd_splicer.sidechain import sidechain_string_dict + AA_CHOICES = [aa[1].upper() for aa in filter(lambda x: x[1].upper() in sidechain_string_dict, AA_CHOICES)] def drawGraph(request, height=470, width=560, xStart=None, yStart=None, xEnd=None, yEnd=None, attribute='Observations', xProperty='phi', yProperty='psi', reference=None, sigmaVal=3, residue_attribute=None, residue_xproperty=None, residue_yproperty=None, xBin=None, yBin=None, background_color='#ffffff',graph_color='#222222',text_color='#000000', hue='green', hash_color='666666'): @@ -74,15 +74,12 @@ def drawGraph(request, height=470, width=560, xStart=None, yStart=None, xEnd=Non text_color, hash_color ) - svg = cdp.Plot() except Exception, e: - print 'exception', e import traceback, sys exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() print "*** print_tb:" traceback.print_tb(exceptionTraceback, limit=10, file=sys.stdout) - raise e return (svg, xStart, xEnd, xBin, yStart, yEnd, yBin) @@ -209,7 +206,6 @@ def renderToSVG(request): return HttpResponse(json.dumps({'errors':errors})) except Exception, e: - print 'exception', e import traceback, sys exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() print "*** print_tb:" diff --git a/pgd_search/search/views.py b/pgd_search/search/views.py index 5b3005e..9fa88f9 100644 --- a/pgd_search/search/views.py +++ b/pgd_search/search/views.py @@ -1,12 +1,11 @@ import math import re import pickle - from django.http import HttpResponse, HttpResponseRedirect from django.template import RequestContext from django.shortcuts import render_to_response, redirect from django.conf import settings -from django.forms.util import ErrorList +from django.forms.utils import ErrorList from django.core.paginator import Paginator, InvalidPage, EmptyPage import json from datetime import datetime @@ -24,7 +23,6 @@ json_sidechain_angles_lookup = json.dumps(bond_angles_string_dict) - def search(request): """ Handler for search form. @@ -43,10 +41,10 @@ def search(request): #at least for now limit the size of the result set count = search_object.querySet().count() if count > settings.QUERY_LIMIT: - form._errors['Result Size'] = ErrorList(['Your query returned more than 20,000 records, refine your search']) + form.error['Result Size'] = ErrorList(['Your query returned more than 20,000 records, refine your search']) elif count == 0 and False: - form._errors['Result Size'] = ErrorList(['Your query returned no results']) + form.error['Result Size'] = ErrorList(['Your query returned no results']) else: #store search in session diff --git a/pgd_search/statistics/aggregates.py b/pgd_search/statistics/aggregates.py index 2a0b40b..75789ed 100644 --- a/pgd_search/statistics/aggregates.py +++ b/pgd_search/statistics/aggregates.py @@ -63,3 +63,4 @@ class BinSort(PGDAggregate): class BinSortSQL(SQLAggregate): sql_function = '' sql_template = '%(function)sFLOOR((IF(%(field)s<%(offset).16f,360,0)+%(field)s-%(offset).16f)/%(bincount).16f)-IF(%(field)s=%(max).16f,1,0)' + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f7bcb35..3935d30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ biopython django-registration-redux django==1.8 +django-pdb selenium mysql-python numpy From c379ba4fb9542f8eca8db8a7d7f50c87a984ac32 Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Fri, 14 Aug 2015 14:26:20 +0530 Subject: [PATCH 3/7] Traceback printing the error --- pgd_search/plot/PlotForm.py | 10 ++++++---- pgd_search/plot/views.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pgd_search/plot/PlotForm.py b/pgd_search/plot/PlotForm.py index d4b1acf..d74ec80 100644 --- a/pgd_search/plot/PlotForm.py +++ b/pgd_search/plot/PlotForm.py @@ -147,11 +147,11 @@ class PlotForm(forms.Form): widget=forms.TextInput(attrs={'size':4})) #custom plot properties - background_color= forms.ChoiceField(choices=BACKGROUND_CHOICES) - graph_color = forms.ChoiceField(choices=GRAPH_CHOICES) - text_color = forms.ChoiceField(choices=TEXT_CHOICES) + background_color= forms.ChoiceField(required=False, choices=BACKGROUND_CHOICES) + graph_color = forms.ChoiceField(required=False, choices=GRAPH_CHOICES) + text_color = forms.ChoiceField(required=False, choices=TEXT_CHOICES) plot_hue = forms.ChoiceField(choices=HUE_CHOICES) - hash_color = forms.ChoiceField(choices=HASH_CHOICES) + hash_color = forms.ChoiceField(required=False, choices=HASH_CHOICES) height = forms.IntegerField(initial=470, widget=forms.TextInput(attrs={'size':4})) width = forms.IntegerField(initial=560, @@ -169,4 +169,6 @@ def clean(self): data['background_color'] = 'Transparent' if not data['graph_color'] : data['graph_color'] = 'Transparent' + if not data['hash_color'] : + data['hash_color'] = 'Transparent' return data diff --git a/pgd_search/plot/views.py b/pgd_search/plot/views.py index 28fbf69..e721de9 100644 --- a/pgd_search/plot/views.py +++ b/pgd_search/plot/views.py @@ -194,6 +194,7 @@ def renderToSVG(request): return HttpResponse(_json) else: + print form.errors """ Errors in the form - repackage the error list as a list of errors This list can then be json serialized and processed by the javascript @@ -206,6 +207,7 @@ def renderToSVG(request): return HttpResponse(json.dumps({'errors':errors})) except Exception, e: + print 'exception', e import traceback, sys exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() print "*** print_tb:" From 210335dd493d60b0521076b2d21869a661c23955 Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Sat, 15 Aug 2015 16:46:19 +0530 Subject: [PATCH 4/7] hacking around ConfDistFuncs.py --- pgd_search/plot/ConfDistFuncs.py | 26 +++++++++++++++++++++----- pgd_search/statistics/aggregates.py | 16 ++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/pgd_search/plot/ConfDistFuncs.py b/pgd_search/plot/ConfDistFuncs.py index fa946c8..90eae61 100644 --- a/pgd_search/plot/ConfDistFuncs.py +++ b/pgd_search/plot/ConfDistFuncs.py @@ -9,15 +9,16 @@ from django.db import connections from django.db.backends.mysql.compiler import SQLCompiler -from django.db.models import Count, Avg, StdDev +from django.db.models import Count, Avg, StdDev, FloatField from pgd_constants import * from pgd_core.models import * from pgd_search.models import * -from pgd_search.statistics.aggregates import DirectionalAvg, DirectionalStdDev, BinSort, PGDAggregate +from pgd_search.statistics.aggregates import DirectionalAvg, DirectionalStdDev, BinSort, PGDAggregate, BinSortSQL from pgd_splicer.sidechain import sidechain_length_relationship_list, sidechain_angle_relationship_list from svg import * +import sys ANGLES = ('ome', 'phi', 'psi', 'chi1','chi2','chi3','chi4','chi5','zeta') NON_FIELDS = ('Observations', 'all') @@ -311,7 +312,7 @@ def query_bins(self): annotations[avg] = Avg(field[1]) annotations[stddev] = StdDev(field[1]) annotated_query = querySet.annotate(**annotations) - + print annotated_query # sort and group by bins using an aggregate function that calculates # bin index based on bin size (in field units ie. degrees) and bin count. # @@ -324,14 +325,29 @@ def query_bins(self): # XXX in Django 1.2+ aggregates were changed to require connection and # SQLCompiler objects to generate sql. We must initialize this all # manually to be able to grab the SQL for just our aggregate. + print "xTextString is :" + print self.xTextString + print "yTextString is " + print self.yTextString + print querySet sortx = BinSort(self.xTextString, offset=x, bincount=xbin, max=x1) sorty = BinSort(self.yTextString, offset=y, bincount=ybin, max=y1) + + pgdaggr = PGDAggregate(self.xTextString, offset=x, bincount=xbin, max=x1) + print "Checking Attribute for PGDAggregate" + print hasattr(pgdaggr, 'aggr') annotated_query.annotate(x=sortx, y=sorty) cn = connections['default'] qn = SQLCompiler(annotated_query.query, cn, 'default').quote_name_unless_alias - sortx_sql = sortx.aggregate.as_sql(qn, cn)[0] - sorty_sql = sorty.aggregate.as_sql(qn, cn)[0] + if not hasattr(sortx, 'queryObj'): + print "doesn't have queryObj" + else : + print "has queryObj" + sortx = BinSortSQL(None,offset=x, bincount=xbin, max=x1) + sorty = BinSortSQL(None,offset=y, bincount=ybin, max=y1) + sortx_sql = sortx.as_sql(qn, cn)[0] + sorty_sql = sorty.as_sql(qn, cn)[0] annotated_query = annotated_query.extra(select={'x':sortx_sql, 'y':sorty_sql}) annotated_query = annotated_query.order_by('x','y') diff --git a/pgd_search/statistics/aggregates.py b/pgd_search/statistics/aggregates.py index 75789ed..0be41c1 100644 --- a/pgd_search/statistics/aggregates.py +++ b/pgd_search/statistics/aggregates.py @@ -6,6 +6,7 @@ class PGDAggregate(Aggregate): Modified to allow Aggregate functions outside of the Django module """ + def add_to_query(self, query, alias, col, source, is_summary): """Add the aggregate to the nominated query. @@ -24,13 +25,24 @@ def add_to_query(self, query, alias, col, source, is_summary): * is_summary is a boolean that is set True if the aggregate is a summary value rather than an annotation. """ + self.queryObj = query klass = globals()['%sSQL' % self.name] aggregate = klass(col, source=source, is_summary=is_summary, **self.extra) - + + print self.extra + + print "alias is :" + print alias + print "col is :" + print col + print "source is : " + print source + # Validate that the backend has a fully supported, correct # implementation of this aggregate + self.aggr = aggregate query.aggregates[alias] = aggregate - self.aggregate = aggregate + class DirectionalStdDev(PGDAggregate): From 529032c655cd9e348abed2cc282fce1395403a3e Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Sun, 16 Aug 2015 02:34:12 +0530 Subject: [PATCH 5/7] fixed the aggregate attribute error --- pgd_search/plot/ConfDistFuncs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pgd_search/plot/ConfDistFuncs.py b/pgd_search/plot/ConfDistFuncs.py index 90eae61..29556d8 100644 --- a/pgd_search/plot/ConfDistFuncs.py +++ b/pgd_search/plot/ConfDistFuncs.py @@ -344,11 +344,13 @@ def query_bins(self): print "doesn't have queryObj" else : print "has queryObj" - sortx = BinSortSQL(None,offset=x, bincount=xbin, max=x1) - sorty = BinSortSQL(None,offset=y, bincount=ybin, max=y1) + sortx = BinSortSQL(('pgd_core_residue', 'psi'), offset=x, bincount=xbin, max=x1) + sorty = BinSortSQL(('pgd_core_residue', 'phi'), offset=y, bincount=ybin, max=y1) sortx_sql = sortx.as_sql(qn, cn)[0] sorty_sql = sorty.as_sql(qn, cn)[0] + + annotated_query = annotated_query.extra(select={'x':sortx_sql, 'y':sorty_sql}) annotated_query = annotated_query.order_by('x','y') From 99fe6b86fd4d830666d38c968739325f72ae2b9c Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Mon, 17 Aug 2015 04:10:03 +0530 Subject: [PATCH 6/7] Fixed the transaction related errors --- pgd/settings.py | 1 + pgd/wsgi.py | 5 ++++- pgd_search/plot/ConfDistFuncs.py | 19 ++++++------------- pgd_search/plot/PlotForm.py | 6 ++++-- pgd_search/plot/views.py | 1 - pgd_search/statistics/aggregates.py | 9 --------- pgd_splicer/ProcessPDBTask.py | 24 ++++++++++++++++-------- 7 files changed, 31 insertions(+), 34 deletions(-) diff --git a/pgd/settings.py b/pgd/settings.py index 5174fc3..7108b18 100644 --- a/pgd/settings.py +++ b/pgd/settings.py @@ -178,6 +178,7 @@ } } +DJANGO_SETTINGS_MODULE = 'pgd.settings' # PGD Specific settings QUERY_LIMIT = config('QUERY_LIMIT', default=50000000, cast=int) SEGMENT_SIZE = config('SEGMENT_SIZE', default=10, cast=int) diff --git a/pgd/wsgi.py b/pgd/wsgi.py index 1e4ba31..25bef95 100644 --- a/pgd/wsgi.py +++ b/pgd/wsgi.py @@ -14,9 +14,12 @@ """ import os +import sys +from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pgd.settings") +#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pgd.settings") +os.environ['DJANGO_SETTINGS_MODULE'] = 'pgd.settings' # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. diff --git a/pgd_search/plot/ConfDistFuncs.py b/pgd_search/plot/ConfDistFuncs.py index 29556d8..557bf7f 100644 --- a/pgd_search/plot/ConfDistFuncs.py +++ b/pgd_search/plot/ConfDistFuncs.py @@ -312,7 +312,7 @@ def query_bins(self): annotations[avg] = Avg(field[1]) annotations[stddev] = StdDev(field[1]) annotated_query = querySet.annotate(**annotations) - print annotated_query + # sort and group by bins using an aggregate function that calculates # bin index based on bin size (in field units ie. degrees) and bin count. # @@ -325,27 +325,20 @@ def query_bins(self): # XXX in Django 1.2+ aggregates were changed to require connection and # SQLCompiler objects to generate sql. We must initialize this all # manually to be able to grab the SQL for just our aggregate. - print "xTextString is :" - print self.xTextString - print "yTextString is " - print self.yTextString - print querySet + sortx = BinSort(self.xTextString, offset=x, bincount=xbin, max=x1) sorty = BinSort(self.yTextString, offset=y, bincount=ybin, max=y1) - pgdaggr = PGDAggregate(self.xTextString, offset=x, bincount=xbin, max=x1) - print "Checking Attribute for PGDAggregate" - print hasattr(pgdaggr, 'aggr') annotated_query.annotate(x=sortx, y=sorty) cn = connections['default'] qn = SQLCompiler(annotated_query.query, cn, 'default').quote_name_unless_alias - if not hasattr(sortx, 'queryObj'): - print "doesn't have queryObj" - else : - print "has queryObj" + + #Hack : Using the BinSortSQL class directly instead of BinSort + #this overrides l:329 and l:330 sortx = BinSortSQL(('pgd_core_residue', 'psi'), offset=x, bincount=xbin, max=x1) sorty = BinSortSQL(('pgd_core_residue', 'phi'), offset=y, bincount=ybin, max=y1) + sortx_sql = sortx.as_sql(qn, cn)[0] sorty_sql = sorty.as_sql(qn, cn)[0] diff --git a/pgd_search/plot/PlotForm.py b/pgd_search/plot/PlotForm.py index d74ec80..fd29a5d 100644 --- a/pgd_search/plot/PlotForm.py +++ b/pgd_search/plot/PlotForm.py @@ -168,7 +168,9 @@ def clean(self): if not data['background_color'] : data['background_color'] = 'Transparent' if not data['graph_color'] : - data['graph_color'] = 'Transparent' + data['graph_color'] = 'Dark Gray' if not data['hash_color'] : - data['hash_color'] = 'Transparent' + data['hash_color'] = 'Gray' + if not data['text_color'] : + data['text_color'] = 'Black' return data diff --git a/pgd_search/plot/views.py b/pgd_search/plot/views.py index e721de9..afffc33 100644 --- a/pgd_search/plot/views.py +++ b/pgd_search/plot/views.py @@ -194,7 +194,6 @@ def renderToSVG(request): return HttpResponse(_json) else: - print form.errors """ Errors in the form - repackage the error list as a list of errors This list can then be json serialized and processed by the javascript diff --git a/pgd_search/statistics/aggregates.py b/pgd_search/statistics/aggregates.py index 0be41c1..ac31b1a 100644 --- a/pgd_search/statistics/aggregates.py +++ b/pgd_search/statistics/aggregates.py @@ -29,15 +29,6 @@ def add_to_query(self, query, alias, col, source, is_summary): klass = globals()['%sSQL' % self.name] aggregate = klass(col, source=source, is_summary=is_summary, **self.extra) - print self.extra - - print "alias is :" - print alias - print "col is :" - print col - print "source is : " - print source - # Validate that the backend has a fully supported, correct # implementation of this aggregate self.aggr = aggregate diff --git a/pgd_splicer/ProcessPDBTask.py b/pgd_splicer/ProcessPDBTask.py index 5191e9d..a9c8bfc 100755 --- a/pgd_splicer/ProcessPDBTask.py +++ b/pgd_splicer/ProcessPDBTask.py @@ -32,6 +32,7 @@ from Bio.PDB import calc_angle as pdb_calc_angle from Bio.PDB import calc_dihedral as pdb_calc_dihedral from django.db import transaction +import django from tools import localfile @@ -47,6 +48,7 @@ from pgd_splicer.chi import CHI_MAP, CHI_CORRECTIONS_TESTS, CHI_CORRECTIONS from pgd_splicer.sidechain import bond_angles, bond_lengths +django.setup() def NO_VALUE(field): """ @@ -215,7 +217,7 @@ def process_pdb(pdb): """ Process an individual pdb file """ - + transaction.set_autocommit(False) # create a copy of the data. This dict will have a large amount of data # added to it as the protein is processed. This prevents memory leaks # due to the original dict having a reference held outside this method. @@ -249,8 +251,10 @@ def process_pdb(pdb): protein.rfactor = float(data['rfactor']) protein.rfree = float(data['rfree']) protein.pdb_date = data['pdb_date'] - protein.save() + with transaction.atomic(): + protein.save() + transaction.commit() # 3) Get/Create Chains and save values chains = {} for chaincode, residues in data['chains'].items(): @@ -264,9 +268,10 @@ def process_pdb(pdb): chain.id = chainId chain.protein = protein chain.code = chaincode - chain.save() + with transaction.atomic(): + chain.save() - protein.chains.add(chain) + protein.chains.add(chain) #create dictionary of chains for quick access chains[chaincode] = chain @@ -305,17 +310,20 @@ def process_pdb(pdb): except: sidechain = klass() sidechain.__dict__.update(residue_props['sidechain']) - sidechain.save() + with transaction.atomic(): + sidechain.save() residue.__setattr__(name, sidechain) # 4e) save - residue.save() - chain.residues.add(residue) + with transaction.atomic(): + residue.save() + chain.residues.add(residue) # 4f) Update old_residue.next if "prev" in residue_props: old_residue.next = residue - old_residue.save() + with transaction.atomic(): + old_residue.save() old_residue = residue From 41afccac2cfcb2857145a92daf4c1903f42ff848 Mon Sep 17 00:00:00 2001 From: "Ramana.S" Date: Tue, 18 Aug 2015 14:54:13 +0530 Subject: [PATCH 7/7] Fixed the error while saving images --- pgd_search/plot/PlotForm.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pgd_search/plot/PlotForm.py b/pgd_search/plot/PlotForm.py index fd29a5d..2fc5df2 100644 --- a/pgd_search/plot/PlotForm.py +++ b/pgd_search/plot/PlotForm.py @@ -165,12 +165,10 @@ def clean(self): data['attribute'] = data['attribute'].replace('-','_') except KeyError: pass - if not data['background_color'] : - data['background_color'] = 'Transparent' if not data['graph_color'] : - data['graph_color'] = 'Dark Gray' + data['graph_color'] = '#222222' if not data['hash_color'] : - data['hash_color'] = 'Gray' + data['hash_color'] = '#666666' if not data['text_color'] : - data['text_color'] = 'Black' + data['text_color'] = '#000000' return data