Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ web:
- "8000:8000"
links:
- mysql
environment:
- PYTHONUNBUFFERED=0
2 changes: 1 addition & 1 deletion pgd/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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 = (
Expand Down
3 changes: 3 additions & 0 deletions pgd_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Protein(models.Model):
# updates allowing up-to-date proteins to be skipped.
pdb_date = models.DateTimeField()

#Deposition date retrieved from the protein file
deposition_date = models.DateTimeField(null=True)

# JMT: upgrade to Django 1.6 caused deadlocks on insert
class Meta:
select_on_save = True
Expand Down
45 changes: 45 additions & 0 deletions pgd_search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from math import ceil
import re
import cPickle
import pytz

from django import forms
from django.conf import settings
Expand All @@ -14,6 +15,7 @@
from pgd_splicer.sidechain import bond_lengths_string_dict, bond_angles_string_dict
from pgd_core.util import residue_indexes

import datetime

range_re = re.compile("(?<=[^-<>=])-")
comp_re = re.compile("^([<>]=?)?")
Expand Down Expand Up @@ -148,6 +150,49 @@ def parse_search(self):
if data.threshold != None:
query = query.filter(protein__threshold__lte=data.threshold)

#...filter protein by date
if data.depositiondate != None :
range_list = data.depositiondate.split(',')
#Setting upper bound in future and lower bound way back in past
#This is done if the users doesn't give the initial values
lower_bound, higher_bound = 1900, 2020

upper_strict, lower_strict = False, False
end_year, start_year = None, None
for qstring in range_list:
qstring = qstring.strip()
if '<=' in qstring:
higher_bound = qstring.strip('<=')

elif '<' in qstring:
higher_bound = qstring.strip('<')
lower_strict = True

elif '>=' in qstring:
lower_bound = qstring.strip('>=')

elif '>' in qstring :
lower_bound = qstring.strip('>')
upper_strict = True

if lower_bound :
start_year = datetime.datetime(int(lower_bound), 1, 1, tzinfo=pytz.timezone('UTC'))
if higher_bound :
end_year = datetime.datetime(int(higher_bound), 1, 1, tzinfo=pytz.timezone('UTC'))

if lower_strict and upper_strict:
query = query.filter(protein__deposition_date__lt=end_year,protein__deposition_date__gt=start_year)

elif lower_strict and not upper_strict :
query = query.filter(protein__deposition_date__lt=end_year,protein__deposition_date__gte=start_year)

elif not lower_strict and upper_strict :
query = query.filter(protein__deposition_date__lte=end_year,protein__deposition_date__gt=start_year)

else :
query = query.filter(protein__deposition_date__lte=end_year,protein__deposition_date__gte=start_year)


# ...filter by query strings (for values and value ranges)...
def compare(x,y):
if x == y:
Expand Down
1 change: 1 addition & 0 deletions pgd_search/search/SearchForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SearchFormBase(Form):
widget=HiddenInput(attrs={'class':'include'}))
residues = ChoiceField(choices=[(i,i) for i in range(1, settings.SEGMENT_SIZE+1)],
initial=3)
depositiondate = CharField(required=False)

# Build a dict for the fields of variable number
form_dict = {'__module__' : 'pgd_search.views'}
Expand Down
1 change: 1 addition & 0 deletions pgd_search/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<td class="label">R-free</td>
<td class="field">{{form.rfreeMin}} - {{form.rfreeMax}}</td>
</tr>

<tr>
<td class="label">{{form.threshold.label}}</td>

Expand Down
9 changes: 8 additions & 1 deletion pgd_splicer/ProcessPDBTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def process_pdb(data):
protein.rfactor = float(data['rfactor'])
protein.rfree = float(data['rfree'])
protein.pdb_date = data['pdb_date']
protein.deposition_date = data['deposition_date']
protein.save()

# 3) Get/Create Chains and save values
Expand Down Expand Up @@ -352,7 +353,7 @@ def pdb_file_is_newer(data):
def amino_present(s):
"""
Whether a given line contains a valid amino acid.

NB: "SEC" is a valid amino acid, regardless of its absence from
AA3to1.

Expand Down Expand Up @@ -407,6 +408,9 @@ def parseWithBioPython(path, props, chains_filter=None):

structure = Bio.PDB.PDBParser().get_structure('pdbname',
decompressed.name)

header = Bio.PDB.parse_pdb_header(decompressed)
props['deposition_date'] = datetime.strptime(header['deposition_date'], "%Y-%m-%d")

# dssp can't do multiple models. if we ever need to, we'll have to
# iterate through them
Expand Down Expand Up @@ -680,6 +684,9 @@ def parseWithBioPython(path, props, chains_filter=None):

print 'Processed %s residues' % len(residues)

prop_file = open('props.txt', 'a+')
prop_file.write(str(props))
prop_file.close()
return props


Expand Down
Loading