switch for respa, D aminoacids, saxs tutorial, license
[django_unres.git] / django_simple / todo / jobfiles.py
index f28e4e0..2badbc2 100644 (file)
@@ -48,15 +48,13 @@ def write_on_task_save(sender, instance, **kwargs):
 WSCLOC=0.10554 WTOR=1.34316 WTORD=1.26571 WCORRH=0.19212 WCORR5=0.00000        &
 WCORR6=0.00000 WEL_LOC=0.37357 WTURN3=1.40323 WTURN4=0.64673 WTURN6=0.00000    &
 WVDWPP=0.23173 WHPB=1.00000 WSCCOR=0.25                                        &
-CUTOFF=7.00000 WCORR4=0.00000
-"""
+CUTOFF=7.00000 WCORR4=0.00000"""
      else:
       w="""WSC=0.82686 WSCP=0.96947 WELEC=0.79373 WBOND=1.00000 WANG=0.46542              &
 WSCLOC=0.07969 WTOR=0.81684 WTORD=0.67806 WCORRH=0.00000 WCORR5=0.00000        &
 WCORR6=0.00000 WEL_LOC=0.71100 WTURN3=2.30298 WTURN4=0.86517 WTURN6=0.00000    &
 WSCCOR=0.14577 WVDWPP=0.17781 WHPB=1.00000 WSCP14=0.00000                      &
-CUTOFF=7.00000 WCORR4=0.00000
-"""
+CUTOFF=7.00000 WCORR4=0.00000"""
      
 
      with open(instance.jobdirname+'/file.inp','w') as f:
@@ -66,7 +64,10 @@ CUTOFF=7.00000 WCORR4=0.00000
 
           control_line = 'SEED='+str(instance.md_seed)+' ' \
              + instance.min_choice \
-             + ' pdbstart pdbref BOXX=1000. BOXY=1000. BOXZ=1000. '
+             + ' pdbstart pdbref ' \
+             + ' BOXX='+str(instance.boxx) \
+             + ' BOXY='+str(instance.boxy) \
+             + ' BOXZ='+str(instance.boxz) +' '
           if not instance.min_overlap:
             control_line = control_line+'overlap '
           if not instance.min_searchsc:
@@ -89,7 +90,7 @@ CUTOFF=7.00000 WCORR4=0.00000
           if seq[-1]=='X':
             dimen3-=1
   
-       nogly ='CDSQKIPTFNHLRWAVEYM'
+       nogly ='CDSQKIPTFNHLRWAVEYMcdsqkiptfnhlrwaveym'
        seq2 = ''.join([c for c in seq if c in nogly])
   
        dimen3=(dimen3+len(seq2))*3
@@ -97,7 +98,11 @@ CUTOFF=7.00000 WCORR4=0.00000
             
        if instance.type == 'md' :
           control_line = 'SEED='+str(instance.md_seed)+' '\
-           +instance.md_start +' md one_letter BOXX=1000. BOXY=1000. BOXZ=1000. '
+           +instance.md_start +' md one_letter'\
+           + ' BOXX='+str(instance.boxx) \
+           + ' BOXY='+str(instance.boxy) \
+           + ' BOXZ='+str(instance.boxz) +' '
+
           if instance.md_pdbref:
              control_line = control_line+'pdbref '
             
@@ -120,10 +125,23 @@ CUTOFF=7.00000 WCORR4=0.00000
 
        if instance.type == 'remd' :
           control_line = 'SEED='+str(instance.md_seed)+' '\
-           +instance.md_start +' re one_letter BOXX=1000. BOXY=1000. BOXZ=1000. '
+           +instance.md_start +' re one_letter'\
+           + ' BOXX='+str(instance.boxx) \
+           + ' BOXY='+str(instance.boxy) \
+           + ' BOXZ='+str(instance.boxz) +' '
+           
           if instance.md_pdbref:
              control_line = control_line+'pdbref '
-           
+          
+          cntrl_saxs=''
+          if instance.saxs_data != '':
+             lines=instance.saxs_data.split('\n')
+             nsaxs=0
+             for line in lines:
+              if len(line.split())==2:
+               nsaxs+=1 
+             cntrl_saxs=' nsaxs='+str(nsaxs)+' scal_rad='+str(instance.scal_rad) 
+             control_line += cntrl_saxs             
             
           type_line = 'reset_vel='+ str(instance.remd_nstex)\
              +' nstep='+str(instance.md_nstep)\
@@ -184,8 +202,10 @@ CUTOFF=7.00000 WCORR4=0.00000
           for element in word_list[:-1]:
               f.write('{:79}'.format(element)+'&\n')
           f.write(word_list[-1]+'\n')
-
-       f.write(w)
+       
+       if instance.saxs_data != '':
+         w+=' wsaxs='+str(instance.wsaxs)
+       f.write(w+'\n')
 
 
        if instance.type == 'min' or instance.md_start == 'pdbstart':
@@ -212,7 +232,12 @@ CUTOFF=7.00000 WCORR4=0.00000
              f.write(seq[i:i+80]+'\n')
           f.write('0\n0\n')
 
-
+       if instance.saxs_data != '':
+             lines=instance.saxs_data.split('\n')
+             for line in lines:
+              tmp=line.split()
+              if len(tmp)==2:
+               f.write(tmp[0]+' '+tmp[1]+'\n') 
        
         
      if instance.type == 'min':
@@ -231,7 +256,7 @@ CUTOFF=7.00000 WCORR4=0.00000
         f1 = open('../files/pbs_md_new.csh', 'r') 
       f2 = open('pbs.csh', 'w')
       for line in f1:
-           f2.write(line.replace('$dimen3',str(dimen3) ))
+           f2.write(line.replace('$dimen3',str(dimen3)+' '+str(instance.md_temp) ))
       f1.close()
       f2.close()  
 
@@ -253,6 +278,21 @@ CUTOFF=7.00000 WCORR4=0.00000
         pbs = '#PBS -l nodes='+str(nodes)+':ppn=4'
       else:
         pbs = '#PBS -l nodes='+str(nodes)+':ppn=4+1:ppn='+str(reszta)
+        
+      tmp_ss=''
+      if instance.ssbond!='':
+        ix=[]
+        ii=0
+        for i in range(0,len(seq)):
+           if seq[i]=='X':
+              ii=ii+1
+           ix.append(ii)
+        l=[]
+        ss=json.loads(instance.ssbond)
+        for e in ss:
+           l.append(e[0]-ix[e[0]])
+           l.append(e[1]-ix[e[1]])
+        tmp_ss=' '.join(map(str,l))
 
       os.chdir(instance.jobdirname)
       if  instance.unres_ff =='E0LL2Y':
@@ -263,6 +303,8 @@ CUTOFF=7.00000 WCORR4=0.00000
       for line in f1:
           if '#PBS -l nodes=4:ppn=4' in line:
            f2.write(line.replace('#PBS -l nodes=4:ppn=4', pbs))
+          elif '$ssbond' in line:
+           f2.write(line.replace('$ssbond',tmp_ss))
           else:
            tmp1=json.loads(instance.remd_multi_t)
            f2.write(line.replace('$temperatures','"'+" ".join(tmp1)+'" '+str(nreplicas)))
@@ -278,19 +320,32 @@ CUTOFF=7.00000 WCORR4=0.00000
               isampl=int(instance.md_nstep/instance.md_ntwx*nreplicas/8000)
 
           if instance.md_pdbref:
-            f.write('SEED='+str(instance.md_seed)+' isampl='+str(isampl)+
-               ' einicheck=1 rescale=2 delta=0.02 cxfile classify\n')
+            f.write('{:79}'.format('SEED='+str(instance.md_seed)+' isampl='+str(isampl)+
+               ' einicheck=1 rescale=2 delta=0.02 cxfile classify')+'&\n')
+            f.write('BOXX='+str(instance.boxx)+' BOXY='+str(instance.boxy)+
+                    ' BOXZ='+str(instance.boxz)+cntrl_saxs +'\n')
           else:    
-            f.write('SEED='+str(instance.md_seed)+' isampl='+str(isampl)+
-              ' einicheck=1 rescale=2 delta=0.02 cxfile\n')
+            f.write('{:79}'.format('SEED='+str(instance.md_seed)+' isampl='+str(isampl)+
+              ' einicheck=1 rescale=2 delta=0.02 cxfile')+'&\n')
+            f.write('BOXX='+str(instance.boxx)+' BOXY='+str(instance.boxy)+
+                    ' BOXZ='+str(instance.boxz)+cntrl_saxs +'\n')
           f.write('nres='+str(len(seq))+' one_letter\n')
           for i in range(0,len(seq),80):
              f.write(seq[i:i+80]+'\n')
 
           f.write(write_ssbond(instance.ssbond))
 
-
-          f.write(w)
+          if instance.saxs_data != '':
+             fsaxs = open(instance.jobdirname+'/saxs.data', 'w')
+             lines=instance.saxs_data.split('\n')
+             for line in lines:
+              tmp=line.split()
+              if len(tmp)==2:
+               f.write(tmp[0]+' '+tmp[1]+'\n')
+               fsaxs.write(tmp[0]+' '+tmp[1]+'\n') 
+             fsaxs.close()
+
+          f.write(w+'\n')
           f.write('\n')
           f.write('nt='+str(instance.remd_nrep)+' replica read_iset\n')
           tmp1=json.loads(instance.remd_multi_t)
@@ -308,13 +363,21 @@ CUTOFF=7.00000 WCORR4=0.00000
            
       with open(instance.jobdirname+'/file_cluster.inp','w') as f:
           f.write(instance.name + ' UNRES server job'+ '\n')
-          f.write('nres='+str(len(seq))
+          f.write('{:79}'.format('nres='+str(len(seq))
              +' one_letter rescale=2 PRINT_CART PDBOUT=1 iopt=1'
-             +' temper='+str(instance.remd_cluter_temp)+'\n')
-          f.write(w)
+             +' temper='+str(instance.remd_cluter_temp))+'&\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.saxs_data != '':
+             lines=instance.saxs_data.split('\n')
+             for line in lines:
+              tmp=line.split()
+              if len(tmp)==2:
+               f.write(tmp[0]+' '+tmp[1]+'\n') 
       
       os.chdir(instance.jobdirname)  
       ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs8.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)