From f3bfe6e521044d61dee2d8e267d3bd5ed6ba44f7 Mon Sep 17 00:00:00 2001 From: Cezary Czaplewski Date: Tue, 12 Dec 2017 01:56:30 +0100 Subject: [PATCH] missing residues error for pdb file or id --- django_simple/todo/forms.py | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/django_simple/todo/forms.py b/django_simple/todo/forms.py index bfbd094..8fda381 100644 --- a/django_simple/todo/forms.py +++ b/django_simple/todo/forms.py @@ -7,6 +7,29 @@ from .models import FF_CHOICE import json import urllib +def pdb_missing_res(file): + msg='' + newchain = True + ires=[] + for line in file: + if line[0:6] == 'ATOM ' and line[13:15] == 'CA': + i = int(line[22:26]) + if ires and i==ires[-1]: + continue + if newchain or i==ires[-1]+1: + ires.append(i) + newchain = False + else: + msg = 'chain breaks between residues '+\ + str(ires[-1])+' and '+str(i)+\ + ', server cannot add missing residues to PDB file' + break + if line[0:3] == 'TER': + newchain = True + if line[0:3] == 'END': + break + + return(msg) class MultiWidgetBasic(forms.MultiWidget): def __init__(self, count, attrs=None): @@ -66,7 +89,17 @@ class TaskForm_min(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) + class TaskForm_min_a(forms.Form): name = forms.CharField(max_length=20) @@ -111,7 +144,16 @@ class TaskForm_min_a(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) class TaskForm_md(forms.Form): @@ -164,7 +206,16 @@ class TaskForm_md(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) class TaskForm_md_a(forms.Form): @@ -239,7 +290,16 @@ class TaskForm_md_a(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) class TaskForm_remd(forms.Form): @@ -289,7 +349,16 @@ class TaskForm_remd(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) class TaskForm_remd_a(forms.Form): @@ -369,7 +438,16 @@ class TaskForm_remd_a(forms.Form): if test.code != 200: msg = 'wrong pdb code' self.add_error('pdbid', msg) + else: + msg=pdb_missing_res(test) + if msg != '': + self.add_error('pdbid',msg) test.close() + + if file1: + msg=pdb_missing_res(file1) + if msg != '': + self.add_error('file1',msg) -- 1.7.9.5