From d82a989eec06a167258ff6d644dd77292310ddda Mon Sep 17 00:00:00 2001 From: Cezary Czaplewski Date: Mon, 9 Apr 2018 14:49:33 +0200 Subject: [PATCH] docking - beta version, only basic --- django_simple/todo/forms.py | 59 +++++++++++ django_simple/todo/jobfiles.py | 44 +++++++- django_simple/todo/models.py | 9 +- django_simple/todo/templates/details.html | 17 +++- django_simple/todo/templates/edit.html | 12 +++ django_simple/todo/urls.py | 2 + django_simple/todo/views.py | 155 +++++++++++++++++++++++++++-- files/generator_v7 | Bin 0 -> 27173 bytes 8 files changed, 284 insertions(+), 14 deletions(-) create mode 100755 files/generator_v7 diff --git a/django_simple/todo/forms.py b/django_simple/todo/forms.py index c279f08..45e78bf 100644 --- a/django_simple/todo/forms.py +++ b/django_simple/todo/forms.py @@ -495,6 +495,65 @@ class TaskForm_remd_a(forms.Form): self.add_error('md_2d',msg) +class TaskForm_dock(forms.Form): + name = forms.CharField(max_length=40,widget=forms.TextInput(attrs={'size':40, 'maxlength':40})) + + file1 = forms.FileField(label='Upload a PDB file1',required=False, + help_text='starting structure for chain1') + pdbid = forms.CharField(min_length=4,max_length=6,required=False, + widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}), + label='or PDB code (:chain)') + + + file2 = forms.FileField(label='Upload a PDB file2',required=False, + help_text='starting structure for chain2') + pdbid2 = forms.CharField(min_length=4,max_length=6,required=False, + widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}), + label='or PDB code (:chain)') + + + md_nstep = forms.IntegerField(label='NSTEP',initial=200000, + help_text='total number of steps') + md_seed = forms.IntegerField(label='SEED',initial=-39912345, + help_text='seed for random number generator') + + def clean(self): + cleaned_data = super(TaskForm_dock, self).clean() + + file1 = cleaned_data.get("file1") + pdbid = cleaned_data.get("pdbid") + file2 = cleaned_data.get("file2") + pdbid2 = cleaned_data.get("pdbid2") + + + if not (file1 or pdbid): + msg = 'no PDB file or code for chain1' + self.add_error('file1', msg) + + if not (file2 or pdbid2): + msg = 'no PDB file or code for chain2' + self.add_error('file2', msg) + + if pdbid: + msg=pdb_code_chain(pdbid) + if msg != '': + self.add_error('pdbid',msg) + + if file1: + msg=pdb_missing_res_chain(file1,'') + if msg != '': + self.add_error('file1',msg) + + if pdbid2: + msg=pdb_code_chain(pdbid2) + if msg != '': + self.add_error('pdbid2',msg) + + if file2: + msg=pdb_missing_res_chain(file2,'') + if msg != '': + self.add_error('file2',msg) + class TaskForm_list(forms.Form): name = forms.CharField(max_length=40,disabled=True,required=False) diff --git a/django_simple/todo/jobfiles.py b/django_simple/todo/jobfiles.py index 44cf4a4..6328f4e 100644 --- a/django_simple/todo/jobfiles.py +++ b/django_simple/todo/jobfiles.py @@ -164,12 +164,15 @@ CUTOFF=7.00000 WCORR4=0.00000""" if instance.md_mdpdb: type_line = type_line + ' mdpdb ' - if instance.type == 'remd' : + if instance.type == 'remd' or instance.type == 'dock': control_line = 'SEED='+str(instance.md_seed)+' '\ +instance.md_start +' re one_letter'\ + ' BOXX='+str(instance.boxx) \ + ' BOXY='+str(instance.boxy) \ + ' BOXZ='+str(instance.boxz) +' ' + + if instance.type == 'dock': + control_line = control_line+'CONSTR_HOMOL=20 ' if instance.md_pdbref: control_line = control_line+'pdbref ' @@ -221,14 +224,14 @@ CUTOFF=7.00000 WCORR4=0.00000""" f.write(word_list[-1]+'\n') if instance.md_start == 'pdbstart': - if instance.type == 'remd' : + if instance.type == 'remd' or instance.type == 'dock': f.write('print_min_ini print_min_res print_min_stat maxfun='+ str(instance.min_maxfun)+'\n') else: f.write('print_min_ini print_min_res print_min_stat\n') - if instance.type == 'remd' : + if instance.type == 'remd' or instance.type == 'dock': word_list = wrapper.wrap(text=type_line2) for element in word_list[:-1]: f.write('{:79}'.format(element)+'&\n') @@ -254,12 +257,23 @@ CUTOFF=7.00000 WCORR4=0.00000""" if instance.type == 'min' or instance.md_start == 'pdbstart': - f.write('plik.pdb\n') + if instance.type == 'dock': + f.write('model01.pdb\n') + else: + f.write('plik.pdb\n') f.write(write_ssbond(instance.ssbond)) if instance.md_2d == '': f.write('0\n') else: f.write(seq_2d_write(seq_2d_xx(instance.md_2d,seq))) + + if instance.type == 'dock': + f.write('HOMOL_DIST=0.1 HOMOL_ANGLE=1.0 HOMOL_THETA=1.0 HOMOL_SCD=1.0 DIST_CUT=15.0 &\n') + f.write('READ2SIGMA START_FROM_MODELS\n') + for i in range(1,10): + f.write('model0'+str(i)+'.pdb\n') + for i in range(10,21): + f.write('model'+str(i)+'.pdb\n') if instance.type == 'md' and instance.md_start != 'pdbstart': @@ -363,6 +377,9 @@ CUTOFF=7.00000 WCORR4=0.00000""" f2.write(line.replace('#PBS -l nodes=4:ppn=4', pbs)) elif '$ssbond' in line: f2.write(line.replace('$ssbond',tmp_ss)) + elif 'cd $PBS_O_WORKDIR' in line and instance.type == 'dock': + f2.write(line) + f2.write('../files/generator_v7 plik.pdb plik2.pdb\n') else: tmp1=json.loads(instance.remd_multi_t) f2.write(line.replace('$temperatures','"'+" ".join(tmp1)+'" '+str(nreplicas))) @@ -392,6 +409,8 @@ CUTOFF=7.00000 WCORR4=0.00000""" ' einicheck=1 rescale=2 delta=0.02 cxfile')+'&\n') if instance.md_2d != '': f.write('{:79}'.format(' WITH_DIHED_CONSTR')+'&\n') + if instance.type == 'dock': + f.write('{:79}'.format(' n_ene=19 CONSTR_HOMOL=20')+'&\n') f.write('BOXX='+str(instance.boxx)+' BOXY='+str(instance.boxy)+ ' BOXZ='+str(instance.boxz)+cntrl_saxs +'\n') @@ -401,6 +420,14 @@ CUTOFF=7.00000 WCORR4=0.00000""" f.write(write_ssbond(instance.ssbond)) + if instance.type == 'dock': + f.write('HOMOL_DIST=0.1 HOMOL_ANGLE=1.0 HOMOL_THETA=1.0 HOMOL_SCD=1.0 DIST_CUT=15.0 &\n') + f.write('READ2SIGMA \n') + for i in range(1,10): + f.write('model0'+str(i)+'.pdb\n') + for i in range(10,21): + f.write('model'+str(i)+'.pdb\n') + if instance.md_2d != '': f.write(seq_2d_write_50(seq_2d_xx(instance.md_2d,seq))) @@ -449,12 +476,21 @@ CUTOFF=7.00000 WCORR4=0.00000""" +' temper='+str(instance.remd_cluter_temp))+'&\n') if instance.md_2d != '': f.write('{:79}'.format(' WITH_DIHED_CONSTR')+'&\n') + if instance.type == 'dock': + f.write('{:79}'.format(' CONSTR_HOMOL=20')+'&\n') f.write('BOXX='+str(instance.boxx)+' BOXY='+str(instance.boxy)+ ' BOXZ='+str(instance.boxz)+cntrl_saxs +'\n') f.write(w+'\n') for i in range(0,len(seq),80): f.write(seq[i:i+80]+'\n') f.write(write_ssbond(instance.ssbond)) + if instance.type == 'dock': + f.write('HOMOL_DIST=0.1 HOMOL_ANGLE=1.0 HOMOL_THETA=1.0 HOMOL_SCD=1.0 DIST_CUT=15.0 &\n') + f.write('READ2SIGMA \n') + for i in range(1,10): + f.write('model0'+str(i)+'.pdb\n') + for i in range(10,21): + f.write('model'+str(i)+'.pdb\n') if instance.md_2d != '': f.write(seq_2d_write_50(seq_2d_xx(instance.md_2d,seq))) if instance.saxs_data != '': diff --git a/django_simple/todo/models.py b/django_simple/todo/models.py index 3c93f63..fc0f358 100644 --- a/django_simple/todo/models.py +++ b/django_simple/todo/models.py @@ -17,6 +17,10 @@ def user_directory_path(instance, filename): # file will be uploaded to MEDIA_ROOT//plik.pdb return '{0}/{1}'.format(instance.jobdirname, 'plik.pdb') +def user_directory_path2(instance, filename): + # file will be uploaded to MEDIA_ROOT//plik2.pdb + return '{0}/{1}'.format(instance.jobdirname, 'plik2.pdb') + # Create your models here. class Task(models.Model): @@ -85,7 +89,10 @@ class Task(models.Model): scal_rad = models.FloatField(default=1.0) wsaxs = models.FloatField(default=1000.0) saxs_data = models.TextField(max_length=10000,default='') - + +#dock + myfile2 = models.FileField(default='',upload_to=user_directory_path2) + pdbcode2 = models.CharField(max_length=6,default='') # system ready = models.BooleanField(default=False) diff --git a/django_simple/todo/templates/details.html b/django_simple/todo/templates/details.html index af52ac5..783ed7e 100644 --- a/django_simple/todo/templates/details.html +++ b/django_simple/todo/templates/details.html @@ -209,7 +209,7 @@ Created {{ task.created_date }} {% endif %} - {% if task.type == "remd" %} + {% if task.type == "remd" or task.type == "dock" %}
  • nrep
    @@ -228,6 +228,17 @@ Created {{ task.created_date }}
    pdb code
    {{ task.pdbcode }}
  • + {% if task.type == "dock" %} +
  • +
    input pdb2
    +
    {{ task.myfile2 }}
    +
  • +
  • +
    pdb code2
    +
    {{ task.pdbcode2 }}
    +
  • + + {% endif %}
  • seed
    {{ task.md_seed}}
    @@ -506,7 +517,7 @@ Created {{ task.created_date }} {% endif %} - {% if task.type == "remd" %} + {% if task.type == "remd" or task.type == "dock" %}
  • Energy histogram
    @@ -786,7 +797,7 @@ $('.majorpointslegend').click(function(){ }); -{% if task.type == "remd" %} +{% if task.type == "remd" or task.type == "dock" %}