UNRES-Dock peptide sequence no pdb
authorCezary Czaplewski <czarek@chem.univ.gda.pl>
Tue, 25 Feb 2020 23:16:59 +0000 (00:16 +0100)
committerCezary Czaplewski <czarek@chem.univ.gda.pl>
Tue, 25 Feb 2020 23:16:59 +0000 (00:16 +0100)
django_simple/todo/forms.py
django_simple/todo/jobfiles.py
django_simple/todo/models.py
django_simple/todo/views.py

index 5746644..68e3f50 100644 (file)
@@ -4,6 +4,7 @@ from .models import MIN_CHOICE
 from .models import MD_START
 from .models import MD_LANG
 from .models import FF_CHOICE
+from django.utils.safestring import mark_safe
 import json
 import urllib
 
@@ -505,6 +506,13 @@ class TaskForm_dock(forms.Form):
       label='or PDB code (:chain)')                   
 
 
+     md_seq = forms.CharField(label=mark_safe('Sequence of chain2 <br /> for dock peptide'),
+                     help_text='aminoacid sequence using one letter code<br>'+
+                        'field is ignored when uploading PDB file2',
+                     required=False,
+                     widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
+
+
      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,
@@ -517,7 +525,7 @@ class TaskForm_dock(forms.Form):
      md_seed = forms.IntegerField(label='SEED',initial=-39912345,
                   help_text='seed for random number generator')
      dock_peptide = forms.BooleanField(required=False,initial=False,
-            label='dock peptide',help_text='no constraints on 2nd chain')                  
+            label='dock peptide',help_text='no constraints on chain2')                  
                   
      def clean(self):
              cleaned_data = super(TaskForm_dock, self).clean()
@@ -526,14 +534,15 @@ class TaskForm_dock(forms.Form):
              pdbid = cleaned_data.get("pdbid")
              file2 = cleaned_data.get("file2")
              pdbid2 = cleaned_data.get("pdbid2")
+             md_seq = cleaned_data.get("md_seq")
 
               
              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'
+             if not (file2 or pdbid2 or md_seq):
+                msg = 'no PDB file or code or sequence for chain2'
                 self.add_error('file2', msg)
 
              if pdbid:
@@ -565,6 +574,12 @@ class TaskForm_dock_a(forms.Form):
       widget=forms.TextInput(attrs={'size':6, 'maxlength':6, 'title':'PDB code or PDB code:chain id'}),
       label='or PDB code (:chain)')                   
 
+     md_seq = forms.CharField(label=mark_safe('Sequence of chain2 <br /> for dock peptide'),
+                     help_text='aminoacid sequence using one letter code<br>'+
+                        'field is ignored when uploading PDB file2',
+                     required=False,
+                     widget=forms.Textarea(attrs={'cols': 70, 'rows': 2}))
+
 
      file2 = forms.FileField(label='Upload a PDB file2',required=False,
                   help_text='starting structure for chain2')
@@ -613,14 +628,14 @@ class TaskForm_dock_a(forms.Form):
              pdbid = cleaned_data.get("pdbid")
              file2 = cleaned_data.get("file2")
              pdbid2 = cleaned_data.get("pdbid2")
-
+             md_seq = cleaned_data.get("md_seq")
               
              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'
+             if not (file2 or pdbid2 or md_seq):
+                msg = 'no PDB file or code or sequence for chain2'
                 self.add_error('file2', msg)
 
              if pdbid:
index e7ee716..5248031 100644 (file)
@@ -408,6 +408,17 @@ CUTOFF=7.00000 WCORR4=0.00000"""
            f2.write(line.replace('$ssbond',tmp_ss))
           elif 'cd $PBS_O_WORKDIR' in line and instance.type == 'dock':
             f2.write(line)
+            if instance.md_seq2 !='':
+             f2.write("""setenv FGPROCS 2
+setenv POT GB
+setenv PREFIX file2
+setenv OUT1FILE YES
+/users2/local/mpich2-1.4.1p1_intel/bin/mpirun -machinefile $PBS_NODEFILE -np 2 $UNRES_BIN
+/users2/local/pulchra306/pulchra -q -g file2_MD000.pdb
+cat file2_MD000.rebuilt.pdb |grep -v TER |grep -v END > tmp_plik2.pdb
+/users2/local/mmtsb/perl/convpdb.pl -renumber 1 -out generic tmp_plik2.pdb > act.rebuilt.pdb
+/users2/local/scwrl4/Scwrl4 -h -i act.rebuilt.pdb -o plik2.pdb
+rm tmp_plik2.pdb act.rebuilt.pdb\n""")
             if instance.dock_peptide:
              f2.write('../files/generator_v13 plik.pdb plik2.pdb 1 \n')
             else:
@@ -542,6 +553,44 @@ CUTOFF=7.00000 WCORR4=0.00000"""
               if len(tmp)==2:
                f.write(tmp[0]+' '+tmp[1]+'\n') 
       
+      if instance.type == 'dock' and instance.md_seq2 != '':
+         with open(instance.jobdirname+'/file2.inp','w') as f:
+           f.write(instance.name + ' chain2 random start'+ '\n')
+           control_line = 'SEED='+str(instance.md_seed)+' '\
+            +'rand_conf md one_letter'\
+            + ' BOXX=1000 BOXY=1000 BOXZ=1000 '
+           
+           if instance.unres_ff =='NEWCT-9P':
+             control_line = control_line+'tormode=2 cart'
+           
+           type_line = '        reset_vel=0'\
+             +' t_bath=300'\
+             +' nstep=100000'\
+             +' ntwe=10000'\
+             +' ntwx=100000'\
+             +' dt=0.2 lang=1 scal_fric=0.02 respa mdpdb '
+
+           wrapper = textwrap.TextWrapper(width=70)
+           word_list = wrapper.wrap(text=control_line)
+           for element in word_list[:-1]:
+             f.write('{:79}'.format(element)+'&\n')
+           f.write(word_list[-1]+'\n')
+
+           word_list = wrapper.wrap(text=type_line)
+           for element in word_list[:-1]:
+             f.write('{:79}'.format(element)+'&\n')
+           f.write(word_list[-1]+'\n')
+           
+           f.write(w+'\n')
+           
+           seq=instance.md_seq2.replace(" ","")
+           f.write(str(len(seq))+'\n')
+           for i in range(0,len(seq),80):
+             f.write(seq[i:i+80]+'\n')
+           f.write('0\n')
+           f.write('0\n')
+          
+      
       os.chdir(instance.jobdirname)  
       ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs8.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
       os.chdir('..')
index 622cac3..aa1cf8d 100644 (file)
@@ -95,6 +95,7 @@ class Task(models.Model):
     myfile2 = models.FileField(default='',upload_to=user_directory_path2)        
     pdbcode2 = models.CharField(max_length=6,default='')
     dock_peptide = models.BooleanField(default=False)
+    md_seq2 = models.TextField(max_length=2000,default='')
     
 # system    
     ready = models.BooleanField(default=False)
index 9c4f9ea..1136355 100644 (file)
@@ -764,13 +764,20 @@ def add_dock(request,task_id):
              if pdbid2:
               task.myfile2=load_pdbid(pdbid2,task.jobdirname,'plik2.pdb')
               task.pdbcode2=pdbid2
+              seq2,ssbond2=from_pdb(task.myfile2)
              else:
               task.myfile2=form.cleaned_data["file2"]
+              if not task.myfile2:
+                seq2=seq_add_x(form.cleaned_data["md_seq"])
+                task.md_seq2=seq2
+              else:
+                seq2,ssbond2=from_pdb(task.myfile2)
 
              task.md_ntwx=task.remd_nstex 
              task.md_start="pdbstart"
              task.remd_multi_m='["3", "3", "3", "3", "3", "3", "3", "3"]'
-             task.md_pdbref=True
+             if task.md_seq2 =='':  
+               task.md_pdbref=True
              task.md_respa=False
              task.ssbond=""
              task.dock_peptide=form.cleaned_data["dock_peptide"]
@@ -778,7 +785,7 @@ def add_dock(request,task_id):
              task.md_seq=""
 
              seq1,ssbond1=from_pdb(task.myfile1)
-             seq2,ssbond2=from_pdb(task.myfile2)
+
              
              if seq1[-1]=='X' and seq2[0]=='X':
               seq=seq1+seq2
@@ -800,7 +807,10 @@ def add_dock(request,task_id):
               task.damino=True
 
              box1=dock_box(task.myfile1)
-             box2=dock_box(task.myfile2)
+             if task.myfile2:
+              box2=dock_box(task.myfile2)
+             else:
+              box2=len(task.md_seq2)*2.0
              task.boxx=(box1+box2)*1.2+20
              task.boxy=(box1+box2)*1.2+20
              task.boxz=(box1+box2)*1.2+20
@@ -1123,7 +1133,7 @@ def refresh_done0(task):
          task.results_text=text
 
 
-         if task.md_pdbref and task.type=='remd' or task.type=='dock':
+         if task.md_pdbref and task.type=='remd' or task.type=='dock' and task.md_seq2 == '':
          
           for i in range(1,6):
            try: